home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / man / cat.1 / expect.1 < prev    next >
Text File  |  1995-07-25  |  141KB  |  2,575 lines

  1.  
  2.  
  3.  
  4.      EEEEXXXXPPPPEEEECCCCTTTT((((1111))))       UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV ((((22229999 DDDDeeeecccceeeemmmmbbbbeeeerrrr 1111999999994444))))        EEEEXXXXPPPPEEEECCCCTTTT((((1111))))
  5.  
  6.  
  7.  
  8.      NNNNAAAAMMMMEEEE
  9.           Expect - programmed dialogue with interactive programs,
  10.           Version 5
  11.  
  12.      SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
  13.           eeeexxxxppppeeeecccctttt [ ----ddddDDDDiiiinnnnNNNN ] [ ----cccc _c_m_d_s ] [ ----ffffbbbb ] _c_m_d_f_i_l_e ] [ _a_r_g_s ]
  14.  
  15.      IIIINNNNTTTTRRRROOOODDDDUUUUCCCCTTTTIIIIOOOONNNN
  16.           EEEExxxxppppeeeecccctttt is a program that "talks" to other interactive
  17.           programs according to a script.  Following the script,
  18.           EEEExxxxppppeeeecccctttt knows what can be expected from a program and what
  19.           the correct response should be.  An interpreted language
  20.           provides branching and high-level control structures to
  21.           direct the dialogue.  In addition, the user can take control
  22.           and interact directly when desired, afterward returning
  23.           control to the script.
  24.  
  25.           EEEExxxxppppeeeeccccttttkkkk is a mixture of EEEExxxxppppeeeecccctttt and TTTTkkkk.  It behaves just like
  26.           EEEExxxxppppeeeecccctttt and TTTTkkkk's wwwwiiiisssshhhh.  EEEExxxxppppeeeecccctttt can also be used directly in C
  27.           or C++ (that is, without Tcl).  See libexpect(3).
  28.  
  29.           The name "Expect" comes from the idea of _s_e_n_d/_e_x_p_e_c_t
  30.           sequences popularized by uucp, kermit and other modem
  31.           control programs.  However unlike uucp, EEEExxxxppppeeeecccctttt is
  32.           generalized so that it can be run as a user-level command
  33.           with any program and task in mind.  EEEExxxxppppeeeecccctttt can actually talk
  34.           to several programs at the same time.
  35.  
  36.           For example, here are some things EEEExxxxppppeeeecccctttt can do:
  37.  
  38.                o+   Cause your computer to dial you back, so that you
  39.                    can login without paying for the call.
  40.  
  41.                o+   Start a game (e.g., rogue) and if the optimal
  42.                    configuration doesn't appear, restart it (again and
  43.                    again) until it does, then hand over control to
  44.                    you.
  45.  
  46.                o+   Run fsck, and in response to its questions, answer
  47.                    "yes", "no" or give control back to you, based on
  48.                    predetermined criteria.
  49.  
  50.                o+   Connect to another network or BBS (e.g., MCI Mail,
  51.                    CompuServe) and automatically retrieve your mail so
  52.                    that it appears as if it was originally sent to
  53.                    your local system.
  54.  
  55.                o+   Carry environment variables, current directory, or
  56.                    any kind of information across rlogin, telnet, tip,
  57.                    su, chgrp, etc.
  58.  
  59.           There are a variety of reasons why the shell cannot perform
  60.  
  61.  
  62.  
  63.      Page 1                                          (printed 7/23/95)
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.      EEEEXXXXPPPPEEEECCCCTTTT((((1111))))       UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV ((((22229999 DDDDeeeecccceeeemmmmbbbbeeeerrrr 1111999999994444))))        EEEEXXXXPPPPEEEECCCCTTTT((((1111))))
  71.  
  72.  
  73.  
  74.           these tasks.  (Try, you'll see.) All are possible with
  75.           EEEExxxxppppeeeecccctttt.
  76.  
  77.           In general, EEEExxxxppppeeeecccctttt is useful for running any program which
  78.           requires interaction between the program and the user.  All
  79.           that is necessary is that the interaction can be
  80.           characterized programmatically.  EEEExxxxppppeeeecccctttt can also give the
  81.           user back control (without halting the program being
  82.           controlled) if desired.  Similarly, the user can return
  83.           control to the script at any time.
  84.  
  85.  
  86.      UUUUSSSSAAAAGGGGEEEE
  87.           EEEExxxxppppeeeecccctttt reads _c_m_d_f_i_l_e for a list of commands to execute.
  88.           EEEExxxxppppeeeecccctttt may also be invoked implicitly on systems which
  89.           support the #! notation by marking the script executable,
  90.           and making the first line in your script:
  91.  
  92.                #!/usr/local/bin/expect -f
  93.  
  94.           Of course, the path must accurately describe where EEEExxxxppppeeeecccctttt
  95.           lives.  /usr/local/bin is just an example.
  96.  
  97.           The ----cccc flag prefaces a command to be executed before any in
  98.           the script.  The command should be quoted to prevent being
  99.           broken up by the shell.  This option may be used multiple
  100.           times.  Multiple commands may be executed with a single ----cccc
  101.           by separating them with semicolons.  Commands are executed
  102.           in the order they appear. (When using Expectk, this option
  103.           is specified as ----ccccoooommmmmmmmaaaannnndddd.)
  104.  
  105.           The ----dddd flag enables some diagnostic output, which primarily
  106.           reports internal activity of commands such as eeeexxxxppppeeeecccctttt and
  107.           iiiinnnntttteeeerrrraaaacccctttt.  This flag has the same effect as "exp_internal 1"
  108.           at the beginning of an Expect script, plus the version of
  109.           EEEExxxxppppeeeecccctttt is printed.  (The ssssttttrrrraaaacccceeee command is useful for
  110.           tracing statements, and the ttttrrrraaaacccceeee command is useful for
  111.           tracing variable assignments.) (When using Expectk, this
  112.           option is specified as ----ddddiiiiaaaagggg.)
  113.  
  114.           The ----DDDD flag enables an interactive debugger.  An integer
  115.           value should follow.  The debugger will take control before
  116.           the next Tcl procedure if the value is non-zero or if a ^C
  117.           is pressed (or a breakpoint is hit, or other appropriate
  118.           debugger command appears in the script).  See the README
  119.           file or SEE ALSO (below) for more information on the
  120.           debugger.  (When using Expectk, this option is specified as
  121.           ----DDDDeeeebbbbuuuugggg.)
  122.  
  123.           The ----ffff flag prefaces a file from which to read commands
  124.           from.  The flag itself is optional as it is only useful when
  125.           using the #! notation (see above), so that other arguments
  126.  
  127.  
  128.  
  129.      Page 2                                          (printed 7/23/95)
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.      EEEEXXXXPPPPEEEECCCCTTTT((((1111))))       UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV ((((22229999 DDDDeeeecccceeeemmmmbbbbeeeerrrr 1111999999994444))))        EEEEXXXXPPPPEEEECCCCTTTT((((1111))))
  137.  
  138.  
  139.  
  140.           may be supplied on the command line.  (When using Expectk,
  141.           this option is specified as ----ffffiiiilllleeee.)
  142.  
  143.           By default, the command file is read into memory and
  144.           executed in its entirety.  It is occasionally desirable to
  145.           read files one line at a time.  For example, stdin is read
  146.           this way.  In order to force arbitrary files to be handled
  147.           this way, use the ----bbbb flag.  (When using Expectk, this option
  148.           is specified as ----bbbbuuuuffffffffeeeerrrr.)
  149.  
  150.           If the string "-" is supplied as a filename, standard input
  151.           is read instead.  (Use "./-" to read from a file actually
  152.           named "-".)
  153.  
  154.           The ----iiii flag causes EEEExxxxppppeeeecccctttt to interactively prompt for
  155.           commands instead of reading them from a file.  Prompting is
  156.           terminated via the eeeexxxxiiiitttt command or upon EOF.  See
  157.           iiiinnnntttteeeerrrrpppprrrreeeetttteeeerrrr (below) for more information.  ----iiii is assumed if
  158.           neither a command file nor ----cccc is used.  (When using Expectk,
  159.           this option is specified as ----iiiinnnntttteeeerrrraaaaccccttttiiiivvvveeee.)
  160.  
  161.  
  162.           -------- may be used to delimit the end of the options.  This is
  163.           useful if you want to pass an option-like argument to your
  164.           script without it being interpreted by EEEExxxxppppeeeecccctttt.  This can
  165.           usefully be placed in the #! line to prevent any flag-like
  166.           interpretation by Expect.  For example, the following will
  167.           leave the original arguments (including the script name) in
  168.           the variable _a_r_g_v.
  169.  
  170.                #!/usr/local/bin/expect --
  171.  
  172.           Note that the usual getopt(3) and execve(2) conventions must
  173.           be observed when adding arguments to the #! line.
  174.  
  175.           The file $exp_library/expect.rc is sourced automatically if
  176.           present, unless the ----NNNN flag is used. (When using Expectk,
  177.           this option is specified as ----NNNNOOOORRRRCCCC.) Immediately after this,
  178.           the file ~/.expect.rc is sourced automatically, unless the
  179.           ----nnnn flag is used.  If the environment variable DOTDIR is
  180.           defined, it is treated as a directory and .expect.rc is read
  181.           from there.  (When using Expectk, this option is specified
  182.           as ----nnnnoooorrrrcccc.) This sourcing occurs only after executing any ----cccc
  183.           flags.
  184.  
  185.           Optional _a_r_g_s are constructed into a list and stored in the
  186.           variable named _a_r_g_v.  _a_r_g_c is initialized to the length of
  187.           argv.
  188.  
  189.           _a_r_g_v_0 is defined to be the name of the script (or binary if
  190.           no script is used).  For example, the following prints out
  191.           the name of the script and the first three arguments:
  192.  
  193.  
  194.  
  195.      Page 3                                          (printed 7/23/95)
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.      EEEEXXXXPPPPEEEECCCCTTTT((((1111))))       UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV ((((22229999 DDDDeeeecccceeeemmmmbbbbeeeerrrr 1111999999994444))))        EEEEXXXXPPPPEEEECCCCTTTT((((1111))))
  203.  
  204.  
  205.  
  206.                send_user "$argv0 [lrange $argv 0 2]\n"
  207.  
  208.  
  209.      CCCCOOOOMMMMMMMMAAAANNNNDDDDSSSS
  210.           EEEExxxxppppeeeecccctttt uses _T_c_l (Tool Command Language).  Tcl provides
  211.           control flow (e.g., if, for, break), expression evaluation
  212.           and several other features such as recursion, procedure
  213.           definition, etc.  Commands used here but not defined (e.g.,
  214.           sssseeeetttt, iiiiffff, eeeexxxxeeeecccc) are Tcl commands (see tcl(3)).  EEEExxxxppppeeeecccctttt
  215.           supports additional commands, described below.  Unless
  216.           otherwise specified, commands return the empty string.
  217.  
  218.           Commands are listed alphabetically so that they can be
  219.           quickly located.  However, new users may find it easier to
  220.           start by reading the descriptions of ssssppppaaaawwwwnnnn, sssseeeennnndddd, eeeexxxxppppeeeecccctttt,
  221.           and iiiinnnntttteeeerrrraaaacccctttt, in that order.
  222.  
  223.           Note that the best introduction to the language (both Expect
  224.           and Tcl) is provided in the book "Exploring Expect" (see SEE
  225.           ALSO below).  Examples are included in this man page but
  226.           they are very limited since this man page is meant primarily
  227.           as reference material.
  228.  
  229.           Note that in the text of this man page, "Expect" with an
  230.           uppercase "E" refers to the EEEExxxxppppeeeecccctttt program while "expect"
  231.           with a lower-case "e" refers to the eeeexxxxppppeeeecccctttt command within
  232.           the EEEExxxxppppeeeecccctttt program.)
  233.  
  234.           cccclllloooosssseeee [-_s_l_a_v_e] [-_o_n_e_x_e_c _0|_1] [-_i _s_p_a_w_n__i_d]
  235.                     closes the connection to the current process.
  236.                     Most interactive programs will detect EOF on their
  237.                     stdin and exit; thus cccclllloooosssseeee usually suffices to
  238.                     kill the process as well.  The ----iiii flag declares
  239.                     the process to close corresponding to the named
  240.                     spawn_id.
  241.  
  242.                     Both eeeexxxxppppeeeecccctttt and iiiinnnntttteeeerrrraaaacccctttt will detect when the
  243.                     current process exits and implicitly do a cccclllloooosssseeee.
  244.                     But if you kill the process by, say, "exec kill
  245.                     $pid", you will need to explicitly call cccclllloooosssseeee.
  246.  
  247.                     The ----oooonnnneeeexxxxeeeecccc flag determines whether the spawn id
  248.                     will be closed in any new spawned processes or if
  249.                     the process is overlayed.  To leave a spawn id
  250.                     open, use the value 0.  A non-zero integer value
  251.                     will force the spawn closed (the default) in any
  252.                     new processes.
  253.  
  254.                     The ----ssssllllaaaavvvveeee flag closes the slave associated with
  255.                     the spawn id.  (See "spawn -pty".) When the
  256.                     connection is closed, the slave is automatically
  257.                     closed as well if still open.
  258.  
  259.  
  260.  
  261.      Page 4                                          (printed 7/23/95)
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268.      EEEEXXXXPPPPEEEECCCCTTTT((((1111))))       UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV ((((22229999 DDDDeeeecccceeeemmmmbbbbeeeerrrr 1111999999994444))))        EEEEXXXXPPPPEEEECCCCTTTT((((1111))))
  269.  
  270.  
  271.  
  272.                     No matter whether the connection is closed
  273.                     implicitly or explicitly, you should call wwwwaaaaiiiitttt to
  274.                     clear up the corresponding kernel process slot.
  275.                     cccclllloooosssseeee does not call wwwwaaaaiiiitttt since there is no
  276.                     guarantee that closing a process connection will
  277.                     cause it to exit.  See wwwwaaaaiiiitttt below for more info.
  278.  
  279.           ddddeeeebbbbuuuugggg [[-_n_o_w] _0|_1]
  280.                     controls a Tcl debugger allowing you to step
  281.                     through statements, set breakpoints, etc.
  282.  
  283.                     With no arguments, a 1 is returned if the debugger
  284.                     is not running, otherwise a 0 is returned.
  285.  
  286.                     With a 1 argument, the debugger is started.  With
  287.                     a 0 argument, the debugger is stopped.  If a 1
  288.                     argument is preceded by the ----nnnnoooowwww flag, the
  289.                     debugger is started immediately (i.e., in the
  290.                     middle of the ddddeeeebbbbuuuugggg command itself).  Otherwise,
  291.                     the debugger is started with the next Tcl
  292.                     statement.
  293.  
  294.                     The ddddeeeebbbbuuuugggg command does not change any traps.
  295.                     Compare this to starting Expect with the ----DDDD flag
  296.                     (see above).
  297.  
  298.                     See the README file or SEE ALSO (below) for more
  299.                     information on the debugger.
  300.  
  301.           ddddiiiissssccccoooonnnnnnnneeeecccctttt
  302.                     disconnects a forked process from the terminal.
  303.                     It continues running in the background.  The
  304.                     process is given its own process group (if
  305.                     possible).  Standard I/O is redirected to
  306.                     /dev/null.
  307.  
  308.                     The following fragment uses ddddiiiissssccccoooonnnnnnnneeeecccctttt to continue
  309.                     running the script in the background.
  310.  
  311.                           if [fork]!=0 exit
  312.                           disconnect
  313.                           . . .
  314.  
  315.                     The following script reads a password, and then
  316.                     runs a program every hour that demands a password
  317.                     each time it is run.  The script supplies the
  318.                     password so that you only have to type it once.
  319.                     (See the ssssttttttttyyyy command which demonstrates how to
  320.                     turn off password echoing.)
  321.  
  322.                           send_user "password?\ "
  323.                           expect_user -re "(.*)\n"
  324.  
  325.  
  326.  
  327.      Page 5                                          (printed 7/23/95)
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334.      EEEEXXXXPPPPEEEECCCCTTTT((((1111))))       UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV ((((22229999 DDDDeeeecccceeeemmmmbbbbeeeerrrr 1111999999994444))))        EEEEXXXXPPPPEEEECCCCTTTT((((1111))))
  335.  
  336.  
  337.  
  338.                           for {} 1 {} {
  339.                                 if [fork]!=0 {sleep 3600;continue}
  340.                                 disconnect
  341.                                 spawn priv_prog
  342.                                 expect Password:
  343.                                 send "$expect_out(1,string)\r"
  344.                                 . . .
  345.                                 exit
  346.                           }
  347.  
  348.                     An advantage to using ddddiiiissssccccoooonnnnnnnneeeecccctttt over the shell
  349.                     asynchronous process feature (&) is that EEEExxxxppppeeeecccctttt
  350.                     can save the terminal parameters prior to
  351.                     disconnection, and then later apply them to new
  352.                     ptys.  With &, EEEExxxxppppeeeecccctttt does not have a chance to
  353.                     read the terminal's parameters since the terminal
  354.                     is already disconnected by the time EEEExxxxppppeeeecccctttt
  355.                     receives control.
  356.  
  357.           eeeexxxxiiiitttt [-_o_p_t_s] [_s_t_a_t_u_s]
  358.                     causes EEEExxxxppppeeeecccctttt to exit or otherwise prepare to do
  359.                     so.
  360.  
  361.                     The ----oooonnnneeeexxxxiiiitttt flag causes the next argument to be
  362.                     used as an exit handler.  Without an argument, the
  363.                     current exit handler is returned.
  364.  
  365.                     The ----nnnnooooeeeexxxxiiiitttt flag causes EEEExxxxppppeeeecccctttt to prepare to exit
  366.                     but stop short of actually returning control to
  367.                     the operating system.  The user-defined exit
  368.                     handler is run as well as Expect's own internal
  369.                     handlers.  No further Expect commands should be
  370.                     executed.  This is useful if you are running
  371.                     Expect with other Tcl extensions.  The current
  372.                     interpreter (and main window if in the Tk
  373.                     environment) remain so that other Tcl extensions
  374.                     can clean up.  If Expect's eeeexxxxiiiitttt is called again
  375.                     (however this might occur), the handlers are not
  376.                     rerun.
  377.  
  378.                     Upon exiting, all connections to spawned processes
  379.                     are closed.  Closure will be detected as an EOF by
  380.                     spawned processes.  eeeexxxxiiiitttt takes no other actions
  381.                     beyond what the normal _exit(2) procedure does.
  382.                     Thus, spawned processes that do not check for EOF
  383.                     may continue to run.  (A variety of conditions are
  384.                     important to determining, for example, what
  385.                     signals a spawned process will be sent, but these
  386.                     are system-dependent, typically documented under
  387.                     exit(3).) Spawned processes that continue to run
  388.                     will be inherited by init.
  389.  
  390.  
  391.  
  392.  
  393.      Page 6                                          (printed 7/23/95)
  394.  
  395.  
  396.  
  397.  
  398.  
  399.  
  400.      EEEEXXXXPPPPEEEECCCCTTTT((((1111))))       UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV ((((22229999 DDDDeeeecccceeeemmmmbbbbeeeerrrr 1111999999994444))))        EEEEXXXXPPPPEEEECCCCTTTT((((1111))))
  401.  
  402.  
  403.  
  404.                     _s_t_a_t_u_s (or 0 if not specified) is returned as the
  405.                     exit status of EEEExxxxppppeeeecccctttt.  eeeexxxxiiiitttt is implicitly
  406.                     executed if the end of the script is reached.
  407.  
  408.           eeeexxxxpppp____ccccoooonnnnttttiiiinnnnuuuueeee
  409.                     The command eeeexxxxpppp____ccccoooonnnnttttiiiinnnnuuuueeee allows eeeexxxxppppeeeecccctttt itself to
  410.                     continue executing rather than returning as it
  411.                     normally would.  (See eeeexxxxppppeeeecccctttt for more
  412.                     information.)
  413.  
  414.  
  415.  
  416.           eeeexxxxpppp____ooooppppeeeennnn [_a_r_g_s] [-_i _s_p_a_w_n__i_d]
  417.                     returns a Tcl file identifier that corresponds to
  418.                     the original spawn id.  The file identifier can
  419.                     then be used as if it were opened by Tcl's ooooppppeeeennnn
  420.                     command.  (The spawn id should no longer be used.
  421.                     A wwwwaaaaiiiitttt should not be executed.
  422.  
  423.                     The ----lllleeeeaaaavvvveeeeooooppppeeeennnn flag leaves the spawn id open for
  424.                     access through Expect commands.  A wwwwaaaaiiiitttt must be
  425.                     executed on the spawn id.
  426.  
  427.  
  428.           eeeexxxxpppp____ppppiiiidddd [-_i _s_p_a_w_n__i_d]
  429.                     returns the process id corresponding to the
  430.                     currently spawned process.  If the ----iiii flag is
  431.                     used, the pid returned corresponds to that of the
  432.                     given spawn id.
  433.  
  434.           eeeexxxxppppeeeecccctttt [[-_o_p_t_s] _p_a_t_1 _b_o_d_y_1] ... [-_o_p_t_s] _p_a_t_n [_b_o_d_y_n]
  435.                     waits until one of the patterns matches the output
  436.                     of a spawned process, a specified time period has
  437.                     passed, or an end-of-file is seen.  If the final
  438.                     body is empty, it may be omitted.
  439.  
  440.                     Patterns from the most recent eeeexxxxppppeeeecccctttt____bbbbeeeeffffoooorrrreeee
  441.                     command are implicitly used before any other
  442.                     patterns.  Patterns from the most recent
  443.                     eeeexxxxppppeeeecccctttt____aaaafffftttteeeerrrr command are implicitly used after any
  444.                     other patterns.
  445.  
  446.                     If the arguments to the entire eeeexxxxppppeeeecccctttt statement
  447.                     require more than one line, all the arguments may
  448.                     be "braced" into one so as to avoid terminating
  449.                     each line with a backslash.  In this one case, the
  450.                     usual Tcl substitutions will occur despite the
  451.                     braces.
  452.  
  453.                     If a pattern is the keyword eeeeooooffff, the corresponding
  454.                     body is executed upon end-of-file.  If a pattern
  455.                     is the keyword ttttiiiimmmmeeeeoooouuuutttt, the corresponding body is
  456.  
  457.  
  458.  
  459.      Page 7                                          (printed 7/23/95)
  460.  
  461.  
  462.  
  463.  
  464.  
  465.  
  466.      EEEEXXXXPPPPEEEECCCCTTTT((((1111))))       UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV ((((22229999 DDDDeeeecccceeeemmmmbbbbeeeerrrr 1111999999994444))))        EEEEXXXXPPPPEEEECCCCTTTT((((1111))))
  467.  
  468.  
  469.  
  470.                     executed upon timeout.  If no timeout keyword is
  471.                     used, an implicit null action is executed upon
  472.                     timeout.  The default timeout period is 10 seconds
  473.                     but may be set, for example to 30, by the command
  474.                     "set timeout 30".  An infinite timeout may be
  475.                     designated by the value -1.  If a pattern is the
  476.                     keyword ddddeeeeffffaaaauuuulllltttt, the corresponding body is
  477.                     executed upon either timeout or end-of-file.
  478.  
  479.                     If a pattern matches, then the corresponding body
  480.                     is executed.  eeeexxxxppppeeeecccctttt returns the result of the
  481.                     body (or the empty string if no pattern matched).
  482.                     In the event that multiple patterns match, the one
  483.                     appearing first is used to select a body.
  484.  
  485.                     Each time new output arrives, it is compared to
  486.                     each pattern in the order they are listed.  Thus,
  487.                     you may test for absence of a match by making the
  488.                     last pattern something guaranteed to appear, such
  489.                     as a prompt.  In situations where there is no
  490.                     prompt, you must use ttttiiiimmmmeeeeoooouuuutttt (just like you would
  491.                     if you were interacting manually).
  492.  
  493.                     Patterns are specified in three ways.  By default,
  494.                     patterns are specified as with Tcl's ssssttttrrrriiiinnnngggg mmmmaaaattttcccchhhh
  495.                     command.  (Such patterns are also similar to C-
  496.                     shell regular expressions usually referred to as
  497.                     "glob" patterns).  The ----ggggllll flag may may be used to
  498.                     protect patterns that might otherwise match eeeexxxxppppeeeecccctttt
  499.                     flags from doing so.  Any pattern beginning with a
  500.                     "-" should be protected this way.    (All strings
  501.                     starting with "-" are reserved for future
  502.                     options.)
  503.  
  504.  
  505.                     For example, the following fragment looks for a
  506.                     successful login.  (Note that aaaabbbboooorrrrtttt is presumed to
  507.                     be a procedure defined elsewhere in the script.)
  508.  
  509.                           expect {
  510.                                  busy                {print busy\n ; exp_continue}
  511.                                  failed              abort
  512.                                  "invalid password"  abort
  513.                                  timeout             abort
  514.                                  connected
  515.                           }
  516.  
  517.                     Quotes are necessary on the fourth pattern since
  518.                     it contains a space, which would otherwise
  519.                     separate the pattern from the action.  Patterns
  520.                     with the same action (such as the 3rd and 4th)
  521.                     require listing the actions again.  This can be
  522.  
  523.  
  524.  
  525.      Page 8                                          (printed 7/23/95)
  526.  
  527.  
  528.  
  529.  
  530.  
  531.  
  532.      EEEEXXXXPPPPEEEECCCCTTTT((((1111))))       UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV ((((22229999 DDDDeeeecccceeeemmmmbbbbeeeerrrr 1111999999994444))))        EEEEXXXXPPPPEEEECCCCTTTT((((1111))))
  533.  
  534.  
  535.  
  536.                     avoid by using regexp-style patterns (see below).
  537.                     More information on forming glob-style patterns
  538.                     can be found in the Tcl manual.
  539.  
  540.                     Regexp-style patterns follow the syntax defined by
  541.                     Tcl's rrrreeeeggggeeeexxxxpppp (short for "regular expression")
  542.                     command.  regexp patterns are introduced with the
  543.                     flag ----rrrreeee.  The previous example can be rewritten
  544.                     using a regexp as:
  545.  
  546.                           expect {
  547.                                  busy         {print busy\n ; exp_continue}
  548.                                  -re "failed|invalid password" abort
  549.                                  timeout      abort
  550.                                  connected
  551.                           }
  552.  
  553.                     Both types of patterns are "unanchored".  This
  554.                     means that patterns do not have to match the
  555.                     entire string, but can begin and end the match
  556.                     anywhere in the string (as long as everything else
  557.                     matches).  Use ^ to match the beginning of a
  558.                     string, and $ to match the end.  Note that if you
  559.                     do not wait for the end of a string, your
  560.                     responses can easily end up in the middle of the
  561.                     string as they are echoed from the spawned
  562.                     process.  While still producing correct results,
  563.                     the output can look unnatural.  Thus, use of $ is
  564.                     encouraged if you can exactly describe the
  565.                     characters at the end of a string.
  566.  
  567.                     Note that in many editors, the ^ and $ match the
  568.                     beginning and end of lines respectively. However,
  569.                     because expect is not line oriented, these
  570.                     characters match the beginning and end of the data
  571.                     (as opposed to lines) currently in the expect
  572.                     matching buffer.  (Also, see the note below on
  573.                     "system indigestion.")
  574.  
  575.                     The ----eeeexxxx flag causes the pattern to be matched as
  576.                     an "exact" string.  No interpretation of *, ^, etc
  577.                     is made (although the usual Tcl conventions must
  578.                     still be observed).  Exact patterns are always
  579.                     unanchored.
  580.  
  581.  
  582.                     The ----nnnnooooccccaaaasssseeee flag causes uppercase characters of
  583.                     the output to compare as if they were lowercase
  584.                     characters.  The pattern is not affected.
  585.  
  586.                     While reading output, more than 2000 bytes can
  587.                     force earlier bytes to be "forgotten".  This may
  588.  
  589.  
  590.  
  591.      Page 9                                          (printed 7/23/95)
  592.  
  593.  
  594.  
  595.  
  596.  
  597.  
  598.      EEEEXXXXPPPPEEEECCCCTTTT((((1111))))       UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV ((((22229999 DDDDeeeecccceeeemmmmbbbbeeeerrrr 1111999999994444))))        EEEEXXXXPPPPEEEECCCCTTTT((((1111))))
  599.  
  600.  
  601.  
  602.                     be changed with the function mmmmaaaattttcccchhhh____mmmmaaaaxxxx.  (Note
  603.                     that excessively large values can slow down the
  604.                     pattern matcher.) If _p_a_t_l_i_s_t is ffffuuuullllllll____bbbbuuuuffffffffeeeerrrr, the
  605.                     corresponding body is executed if _m_a_t_c_h__m_a_x bytes
  606.                     have been received and no other patterns have
  607.                     matched.  Whether or not the ffffuuuullllllll____bbbbuuuuffffffffeeeerrrr keyword
  608.                     is used, the forgotten characters are written to
  609.                     expect_out(buffer).
  610.  
  611.                     If _p_a_t_l_i_s_t is the keyword nnnnuuuullllllll, and nulls are
  612.                     allowed (via the rrrreeeemmmmoooovvvveeee____nnnnuuuullllllllssss command), the
  613.                     corresponding body is executed if a single ASCII 0
  614.                     is matched.  It is not possible to match 0 bytes
  615.                     via glob or regexp patterns.
  616.  
  617.                     Upon matching a pattern (or eof or full_buffer),
  618.                     any matching and previously unmatched output is
  619.                     saved in the variable _e_x_p_e_c_t__o_u_t(_b_u_f_f_e_r).  Up to 9
  620.                     regexp substring matches are saved in the
  621.                     variables _e_x_p_e_c_t__o_u_t(_1,_s_t_r_i_n_g) through
  622.                     _e_x_p_e_c_t__o_u_t(_9,_s_t_r_i_n_g).  If the ----iiiinnnnddddiiiicccceeeessss flag is
  623.                     used before a pattern, the starting and ending
  624.                     indices (in a form suitable for llllrrrraaaannnnggggeeee) of the 10
  625.                     strings are stored in the variables
  626.                     _e_x_p_e_c_t__o_u_t(_X,_s_t_a_r_t) and _e_x_p_e_c_t__o_u_t(_X,_e_n_d) where X
  627.                     is a digit, corresponds to the substring position
  628.                     in the buffer.  0 refers to strings which matched
  629.                     the entired pattern and is generated for glob
  630.                     patterns as well as regexp patterns.  For example,
  631.                     if a process has produced output of "abcdefgh\n",
  632.                     the result of:
  633.  
  634.                           expect "cd"
  635.  
  636.                     is as if the following statements had executed:
  637.  
  638.                                  set expect_out(0,string) cd
  639.                                  set expect_out(buffer) abcd
  640.  
  641.                     and "efgh\n" is left in the output buffer.  If a
  642.                     process produced the output "abbbcabkkkka\n", the
  643.                     result of:
  644.  
  645.                                  expect -indices -re "b(b*).*(k+)"
  646.  
  647.                     is as if the following statements had executed:
  648.  
  649.                                  set expect_out(0,start) 1
  650.                                  set expect_out(0,end) 10
  651.                                  set expect_out(0,string) bbbcabkkkk
  652.                                  set expect_out(1,start) 2
  653.                                  set expect_out(1,end) 3
  654.  
  655.  
  656.  
  657.      Page 10                                         (printed 7/23/95)
  658.  
  659.  
  660.  
  661.  
  662.  
  663.  
  664.      EEEEXXXXPPPPEEEECCCCTTTT((((1111))))       UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV ((((22229999 DDDDeeeecccceeeemmmmbbbbeeeerrrr 1111999999994444))))        EEEEXXXXPPPPEEEECCCCTTTT((((1111))))
  665.  
  666.  
  667.  
  668.                                  set expect_out(1,string) bb
  669.                                  set expect_out(2,start) 10
  670.                                  set expect_out(2,end) 10
  671.                                  set expect_out(2,string) k
  672.                                  set expect_out(buffer) abbbcabkkkk
  673.  
  674.                     and "a\n" is left in the output buffer.  The
  675.                     pattern "*" (and -re ".*") will flush the output
  676.                     buffer without reading any more output from the
  677.                     process.
  678.  
  679.                     Normally, the matched output is discarded from
  680.                     Expect's internal buffers.  This may be prevented
  681.                     by prefixing a pattern with the ----nnnnoooottttrrrraaaannnnssssffffeeeerrrr flag.
  682.                     This flag is especially useful in experimenting
  683.                     (and can be abbreviated to "-n" for convenience
  684.                     while experimenting).
  685.  
  686.                     The spawn id associated with the matching output
  687.                     (or eof or full_buffer) is stored in
  688.                     _e_x_p_e_c_t__o_u_t(_s_p_a_w_n__i_d).
  689.  
  690.                     By default, patterns are matched against output
  691.                     from the current process, however the ----iiii flag
  692.                     declares the output from the named spawn_id list
  693.                     be matched against any following patterns (up to
  694.                     the next ----iiii).  The spawn_id list should either be
  695.                     a whitespace separated list of spawn_ids or a
  696.                     variable referring to such a list of spawn_ids.
  697.  
  698.                     For example, the following example waits for
  699.                     "connected" from the current process, or "busy",
  700.                     "failed" or "invalid password" from the spawn_id
  701.                     named by $proc2.
  702.  
  703.                           expect {
  704.                                  -i $proc2 busy{print busy\n ; exp_continue}
  705.                                  -re "failed|invalid password" abort
  706.                                  timeout      abort
  707.                                  connected
  708.                           }
  709.  
  710.                     The value of the global variable _a_n_y__s_p_a_w_n__i_d may
  711.                     be used to match patterns to any spawn_ids that
  712.                     are named with all other ----iiii flags in the current
  713.                     eeeexxxxppppeeeecccctttt command.  The spawn_id from a ----iiii flag with
  714.                     no associated pattern (i.e., followed immediately
  715.                     by another ----iiii) is made available to any other
  716.                     patterns in the same eeeexxxxppppeeeecccctttt command associated
  717.                     with _a_n_y__s_p_a_w_n__i_d.
  718.  
  719.                     The ----iiii flag may also name a global variable in
  720.  
  721.  
  722.  
  723.      Page 11                                         (printed 7/23/95)
  724.  
  725.  
  726.  
  727.  
  728.  
  729.  
  730.      EEEEXXXXPPPPEEEECCCCTTTT((((1111))))       UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV ((((22229999 DDDDeeeecccceeeemmmmbbbbeeeerrrr 1111999999994444))))        EEEEXXXXPPPPEEEECCCCTTTT((((1111))))
  731.  
  732.  
  733.  
  734.                     which case the variable is read for a list of
  735.                     spawn ids.  The variable is reread whenever it
  736.                     changes.  This provides a way of changing the I/O
  737.                     source while the command is in execution.  Spawn
  738.                     ids provided this way are called "indirect" spawn
  739.                     ids.
  740.  
  741.                     Actions such as bbbbrrrreeeeaaaakkkk and ccccoooonnnnttttiiiinnnnuuuueeee cause control
  742.                     structures (i.e., ffffoooorrrr, pppprrrroooocccc) to behave in the
  743.                     usual way.  The command eeeexxxxpppp____ccccoooonnnnttttiiiinnnnuuuueeee allows eeeexxxxppppeeeecccctttt
  744.                     itself to continue executing rather than returning
  745.                     as it normally would.
  746.  
  747.                     This is useful for avoiding explicit loops or
  748.                     repeated expect statements.  The following example
  749.                     is part of a fragment to automate rlogin.  The
  750.                     eeeexxxxpppp____ccccoooonnnnttttiiiinnnnuuuueeee avoids having to write a second
  751.                     eeeexxxxppppeeeecccctttt statement (to look for the prompt again) if
  752.                     the rlogin prompts for a password.
  753.  
  754.                     expect {
  755.                                  Password: {
  756.                                               stty -echo
  757.                                               send_user "password (for $user) on $host: "
  758.                                               expect_user -re "(.*)\n"
  759.                                               send_user "\n"
  760.                                               send "$expect_out(1,string)\r"
  761.                                               stty echo
  762.                                               exp_continue
  763.                                  } incorrect {
  764.                                               send_user "invalid password or account\n"
  765.                                               exit
  766.                                  } timeout {
  767.                                               send_user "connection to $host timed out\n"
  768.                                               exit
  769.                                  } eof {
  770.                                               send_user "connection to host failed: $expect_out(buffer)"
  771.                                               exit
  772.                                  } -re $prompt
  773.                     }
  774.  
  775.                     For example, the following fragment might help a
  776.                     user guide an interaction that is already totally
  777.                     automated.  In this case, the terminal is put into
  778.                     raw mode.  If the user presses "+", a variable is
  779.                     incremented.  If "p" is pressed, several returns
  780.                     are sent to the process, perhaps to poke it in
  781.                     some way, and "i" lets the user interact with the
  782.                     process, effectively stealing away control from
  783.                     the script.  In each case, the eeeexxxxpppp____ccccoooonnnnttttiiiinnnnuuuueeee allows
  784.                     the current eeeexxxxppppeeeecccctttt to continue pattern matching
  785.                     after executing the current action.
  786.  
  787.  
  788.  
  789.      Page 12                                         (printed 7/23/95)
  790.  
  791.  
  792.  
  793.  
  794.  
  795.  
  796.      EEEEXXXXPPPPEEEECCCCTTTT((((1111))))       UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV ((((22229999 DDDDeeeecccceeeemmmmbbbbeeeerrrr 1111999999994444))))        EEEEXXXXPPPPEEEECCCCTTTT((((1111))))
  797.  
  798.  
  799.  
  800.                     stty raw -echo
  801.                     expect_after {
  802.                                  -i $user_spawn_id
  803.                                  "p" {send "\r\r\r"; exp_continue}
  804.                                  "+" {incr foo; exp_continue}
  805.                                  "i" {interact; exp_continue}
  806.                                  "quit" exit
  807.                     }
  808.  
  809.  
  810.                     By default, eeeexxxxpppp____ccccoooonnnnttttiiiinnnnuuuueeee resets the timeout timer.
  811.                     The timer is not restarted, if eeeexxxxpppp____ccccoooonnnnttttiiiinnnnuuuueeee is
  812.                     called with the ----ccccoooonnnnttttiiiinnnnuuuueeee____ttttiiiimmmmeeeerrrr flag.
  813.  
  814.           eeeexxxxppppeeeecccctttt____aaaafffftttteeeerrrr [_e_x_p_e_c_t _a_r_g_s]
  815.                     works identically to the eeeexxxxppppeeeecccctttt____bbbbeeeeffffoooorrrreeee except that
  816.                     if patterns from both eeeexxxxppppeeeecccctttt and eeeexxxxppppeeeecccctttt____aaaafffftttteeeerrrr can
  817.                     match, the eeeexxxxppppeeeecccctttt pattern is used.  See the
  818.                     eeeexxxxppppeeeecccctttt____bbbbeeeeffffoooorrrreeee ccccoooommmmmmmmaaaannnndddd ffffoooorrrr mmmmoooorrrreeee iiiinnnnffffoooorrrrmmmmaaaattttiiiioooonnnn....
  819.  
  820.           eeeexxxxppppeeeecccctttt____bbbbaaaacccckkkkggggrrrroooouuuunnnndddd [_e_x_p_e_c_t _a_r_g_s]
  821.                     takes the same arguments as eeeexxxxppppeeeecccctttt, however it
  822.                     returns immediately.  Patterns are tested whenever
  823.                     new input arrives.  Note: this only works in the
  824.                     Tk environment.  The pattern ttttiiiimmmmeeeeoooouuuutttt and ddddeeeeffffaaaauuuulllltttt
  825.                     are meaningless to eeeexxxxppppeeeecccctttt____bbbbaaaacccckkkkggggrrrroooouuuunnnndddd and are
  826.                     silently discarded.  Otherwise, the
  827.                     eeeexxxxppppeeeecccctttt____bbbbaaaacccckkkkggggrrrroooouuuunnnndddd command uses eeeexxxxppppeeeecccctttt____bbbbeeeeffffoooorrrreeee and
  828.                     eeeexxxxppppeeeecccctttt____aaaafffftttteeeerrrr patterns just like eeeexxxxppppeeeecccctttt does.
  829.  
  830.                     When eeeexxxxppppeeeecccctttt____bbbbaaaacccckkkkggggrrrroooouuuunnnndddd actions are being
  831.                     evaluated, background processing for the same
  832.                     spawn id is blocked.  Background processing is
  833.                     unblocked when the action completes.  While
  834.                     background processing is blocked, it is possible
  835.                     to do a (foreground) eeeexxxxppppeeeecccctttt on the same spawn id.
  836.  
  837.                     It is not possible to execute an eeeexxxxppppeeeecccctttt while an
  838.                     eeeexxxxppppeeeecccctttt____bbbbaaaacccckkkkggggrrrroooouuuunnnndddd is unblocked.  eeeexxxxppppeeeecccctttt____bbbbaaaacccckkkkggggrrrroooouuuunnnndddd
  839.                     for a particular spawn id is deleted by declaring
  840.                     a new expect_background with the same spawn id.
  841.                     Declaring eeeexxxxppppeeeecccctttt____bbbbaaaacccckkkkggggrrrroooouuuunnnndddd with no pattern
  842.                     removes the given spawn id from the ability to
  843.                     match patterns in the background.
  844.  
  845.           eeeexxxxppppeeeecccctttt____bbbbeeeeffffoooorrrreeee [_e_x_p_e_c_t _a_r_g_s]
  846.                     takes the same arguments as eeeexxxxppppeeeecccctttt, however it
  847.                     returns immediately.  Pattern-action pairs from
  848.                     the most recent eeeexxxxppppeeeecccctttt____bbbbeeeeffffoooorrrreeee with the same spawn
  849.                     id are implicitly added to any following eeeexxxxppppeeeecccctttt
  850.                     commands.  If a pattern matches, it is treated as
  851.                     if it had been specified in the eeeexxxxppppeeeecccctttt command
  852.  
  853.  
  854.  
  855.      Page 13                                         (printed 7/23/95)
  856.  
  857.  
  858.  
  859.  
  860.  
  861.  
  862.      EEEEXXXXPPPPEEEECCCCTTTT((((1111))))       UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV ((((22229999 DDDDeeeecccceeeemmmmbbbbeeeerrrr 1111999999994444))))        EEEEXXXXPPPPEEEECCCCTTTT((((1111))))
  863.  
  864.  
  865.  
  866.                     itself, and the associated body is executed in the
  867.                     context of the eeeexxxxppppeeeecccctttt command.  If patterns from
  868.                     both eeeexxxxppppeeeecccctttt____bbbbeeeeffffoooorrrreeee and eeeexxxxppppeeeecccctttt can match, the
  869.                     eeeexxxxppppeeeecccctttt____bbbbeeeeffffoooorrrreeee pattern is used.
  870.  
  871.                     If not pattern is specified, the spawn id is not
  872.                     checked for any patterns.
  873.  
  874.                     Unless overridden by a ----iiii flag, eeeexxxxppppeeeecccctttt____bbbbeeeeffffoooorrrreeee
  875.                     patterns match against the spawn id defined at the
  876.                     time that the eeeexxxxppppeeeecccctttt____bbbbeeeeffffoooorrrreeee command was executed
  877.                     (not when its pattern is matched).
  878.  
  879.                     The -info flag causes eeeexxxxppppeeeecccctttt____bbbbeeeeffffoooorrrreeee to return the
  880.                     current specifications of what patterns it will
  881.                     match.  By default, it reports on the current
  882.                     spawn id.  An optional spawn id specification may
  883.                     be given for information on that spawn id.  For
  884.                     example
  885.  
  886.                                  expect_before -info -i $proc
  887.  
  888.                     At most one spawn id specification may be given.
  889.                     The flag -indirect suppresses direct spawn ids
  890.                     that come only from indirect specifications.
  891.  
  892.                     Instead of a spawn id specification, the flag "-
  893.                     all" will cause "-info" to report on all spawn
  894.                     ids.
  895.  
  896.                     The output of the -info flag can be reused as the
  897.                     argument to expect_before.
  898.  
  899.           eeeexxxxppppeeeecccctttt____ttttttttyyyy [_e_x_p_e_c_t _a_r_g_s]
  900.                     is like eeeexxxxppppeeeecccctttt but it reads characters from
  901.                     /dev/tty (i.e. keystrokes from the user).  By
  902.                     default, reading is performed in cooked mode.
  903.                     Thus, lines must end with a return in order for
  904.                     eeeexxxxppppeeeecccctttt to see them.  This may be changed via ssssttttttttyyyy
  905.                     (see the ssssttttttttyyyy command below).
  906.  
  907.           eeeexxxxppppeeeecccctttt____uuuusssseeeerrrr [_e_x_p_e_c_t _a_r_g_s]
  908.                     is like eeeexxxxppppeeeecccctttt but it reads characters from stdin
  909.                     (i.e. keystrokes from the user).  By default,
  910.                     reading is performed in cooked mode.  Thus, lines
  911.                     must end with a return in order for eeeexxxxppppeeeecccctttt to see
  912.                     them.  This may be changed via ssssttttttttyyyy (see the ssssttttttttyyyy
  913.                     command below).
  914.  
  915.           eeeexxxxpppp____vvvveeeerrrrssssiiiioooonnnn [[-_e_x_i_t] _v_e_r_s_i_o_n]
  916.                     is useful for assuring that the script is
  917.                     compatible with the current version of Expect.
  918.  
  919.  
  920.  
  921.      Page 14                                         (printed 7/23/95)
  922.  
  923.  
  924.  
  925.  
  926.  
  927.  
  928.      EEEEXXXXPPPPEEEECCCCTTTT((((1111))))       UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV ((((22229999 DDDDeeeecccceeeemmmmbbbbeeeerrrr 1111999999994444))))        EEEEXXXXPPPPEEEECCCCTTTT((((1111))))
  929.  
  930.  
  931.  
  932.                     With no arguments, the current version of EEEExxxxppppeeeecccctttt
  933.                     is returned.  This version may then be encoded in
  934.                     your script.  If you actually know that you are
  935.                     not using features of recent versions, you can
  936.                     specify an earlier version.
  937.  
  938.                     Versions consist of three numbers separated by
  939.                     dots.  First is the major number.  Scripts written
  940.                     for versions of EEEExxxxppppeeeecccctttt with a different major
  941.                     number will almost certainly not work.
  942.                     eeeexxxxpppp____vvvveeeerrrrssssiiiioooonnnn returns an error if the major numbers
  943.                     do not match.
  944.  
  945.                     Second is the minor number.  Scripts written for a
  946.                     version with a greater minor number than the
  947.                     current version may depend upon some new feature
  948.                     and might not run.  eeeexxxxpppp____vvvveeeerrrrssssiiiioooonnnn returns an error
  949.                     if the major numbers match, but the script minor
  950.                     number is greater than that of the running EEEExxxxppppeeeecccctttt.
  951.  
  952.                     Third is a number that plays no part in the
  953.                     version comparison.  However, it is incremented
  954.                     when the EEEExxxxppppeeeecccctttt software distribution is changed
  955.                     in any way, such as by additional documentation or
  956.                     optimization.  It is reset to 0 upon each new
  957.                     minor version.
  958.  
  959.                     With the ----eeeexxxxiiiitttt flag, EEEExxxxppppeeeecccctttt prints an error and
  960.                     exits if the version is out of date.
  961.  
  962.           ffffoooorrrrkkkk      creates a new process.  The new process is an
  963.                     exact copy of the current EEEExxxxppppeeeecccctttt process.  On
  964.                     success, ffffoooorrrrkkkk returns 0 to the new (child) process
  965.                     and returns the process ID of the child process to
  966.                     the parent process.  On failure (invariably due to
  967.                     lack of resources, e.g., swap space, memory), ffffoooorrrrkkkk
  968.                     returns -1 to the parent process, and no child
  969.                     process is created.
  970.  
  971.                     Forked processes exit via the eeeexxxxiiiitttt command, just
  972.                     like the original process.  Forked processes are
  973.                     allowed to write to the log files.  If you do not
  974.                     disable debugging or logging in most of the
  975.                     processes, the result can be confusing.
  976.  
  977.                     Some pty implementations may be confused by
  978.                     multiple readers and writers, even momentarily.
  979.                     Thus, it is safest to ffffoooorrrrkkkk before spawning
  980.                     processes.
  981.  
  982.           iiiinnnntttteeeerrrraaaacccctttt [_s_t_r_i_n_g_1 _b_o_d_y_1] ... [_s_t_r_i_n_g_n [_b_o_d_y_n]]
  983.                     gives control of the current process to the user,
  984.  
  985.  
  986.  
  987.      Page 15                                         (printed 7/23/95)
  988.  
  989.  
  990.  
  991.  
  992.  
  993.  
  994.      EEEEXXXXPPPPEEEECCCCTTTT((((1111))))       UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV ((((22229999 DDDDeeeecccceeeemmmmbbbbeeeerrrr 1111999999994444))))        EEEEXXXXPPPPEEEECCCCTTTT((((1111))))
  995.  
  996.  
  997.  
  998.                     so that keystrokes are sent to the current
  999.                     process, and the stdout and stderr of the current
  1000.                     process are returned.
  1001.  
  1002.                     String-body pairs may be specified as arguments,
  1003.                     in which case the body is executed when the
  1004.                     corresponding string is entered.  (By default, the
  1005.                     string is not sent to the current process.)   The
  1006.                     iiiinnnntttteeeerrrrpppprrrreeeetttteeeerrrr command is assumed, if the final body
  1007.                     is missing.
  1008.  
  1009.                     If the arguments to the entire iiiinnnntttteeeerrrraaaacccctttt statement
  1010.                     require more than one line, all the arguments may
  1011.                     be "braced" into one so as to avoid terminating
  1012.                     each line with a backslash.  In this one case, the
  1013.                     usual Tcl substitutions will occur despite the
  1014.                     braces.
  1015.  
  1016.                     For example, the following command runs interact
  1017.                     with the following string-body pairs defined:
  1018.                     When ^Z is pressed, EEEExxxxppppeeeecccctttt is suspended.  (The
  1019.                     ----rrrreeeesssseeeetttt flag restores the terminal modes.) When ^A
  1020.                     is pressed, the user sees "you typed a control-A"
  1021.                     and the process is sent a ^A.  When $ is pressed,
  1022.                     the user sees the date.  When ^C is pressed,
  1023.                     EEEExxxxppppeeeecccctttt exits.  If "foo" is entered, the user sees
  1024.                     "bar".  When ~~ is pressed, the EEEExxxxppppeeeecccctttt interpreter
  1025.                     runs interactively.
  1026.  
  1027.                         set CTRLZ \032
  1028.                         interact {
  1029.                                  -reset $CTRLZ {exec kill -STOP [pid]}
  1030.                                  \001    {send_user "you typed a control-A\n";
  1031.                                           send "\001"
  1032.                                          }
  1033.                                  $       {send_user "The date is [exec date]."}
  1034.                                  \003    exit
  1035.                                  foo     {send_user "bar"}
  1036.                                  ~~
  1037.                         }
  1038.  
  1039.  
  1040.                     In string-body pairs, strings are matched in the
  1041.                     order they are listed as arguments.  Strings that
  1042.                     partially match are not sent to the current
  1043.                     process in anticipation of the remainder coming.
  1044.                     If characters are then entered such that there can
  1045.                     no longer possibly be a match, only the part of
  1046.                     the string will be sent to the process that cannot
  1047.                     possibly begin another match.  Thus, strings that
  1048.                     are substrings of partial matches can match later,
  1049.                     if the original strings that was attempting to be
  1050.  
  1051.  
  1052.  
  1053.      Page 16                                         (printed 7/23/95)
  1054.  
  1055.  
  1056.  
  1057.  
  1058.  
  1059.  
  1060.      EEEEXXXXPPPPEEEECCCCTTTT((((1111))))       UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV ((((22229999 DDDDeeeecccceeeemmmmbbbbeeeerrrr 1111999999994444))))        EEEEXXXXPPPPEEEECCCCTTTT((((1111))))
  1061.  
  1062.  
  1063.  
  1064.                     match ultimately fails.
  1065.  
  1066.                     By default, string matching is exact with no wild
  1067.                     cards.  (In contrast, the eeeexxxxppppeeeecccctttt command uses
  1068.                     glob-style patterns by default.)  The ----eeeexxxx flag may
  1069.                     be used to protect patterns that might otherwise
  1070.                     match iiiinnnntttteeeerrrraaaacccctttt flags from doing so.  Any pattern
  1071.                     beginning with a "-" should be protected this way.
  1072.                     (All strings starting with "-" are reserved for
  1073.                     future options.)
  1074.  
  1075.                     The ----rrrreeee flag forces the string to be interpreted
  1076.                     as a regexp-style pattern.  In this case, matching
  1077.                     substrings are stored in the variable _i_n_t_e_r_a_c_t__o_u_t
  1078.                     similarly to the way eeeexxxxppppeeeecccctttt stores its output in
  1079.                     the variable eeeexxxxppppeeeecccctttt____oooouuuutttt.  The ----iiiinnnnddddiiiicccceeeessss flag is
  1080.                     similarly supported.
  1081.  
  1082.                     The pattern eeeeooooffff introduces an action that is
  1083.                     executed upon end-of-file.  A separate eeeeooooffff pattern
  1084.                     may also follow the ----oooouuuuttttppppuuuutttt flag in which case it
  1085.                     is matched if an eof is detected while writing
  1086.                     output.  The default eeeeooooffff action is "return", so
  1087.                     that iiiinnnntttteeeerrrraaaacccctttt simply returns upon any EOF.
  1088.  
  1089.                     The pattern ttttiiiimmmmeeeeoooouuuutttt introduces a timeout (in
  1090.                     seconds) and action that is executed after no
  1091.                     characters have been read for a given time.  The
  1092.                     ttttiiiimmmmeeeeoooouuuutttt pattern applies to the most recently
  1093.                     specified process.  There is no default timeout.
  1094.                     The special variable "timeout" (used by the eeeexxxxppppeeeecccctttt
  1095.                     command) has no affect on this timeout.
  1096.  
  1097.                     For example, the following statement could be used
  1098.                     to autologout users who have not typed anything
  1099.                     for an hour but who still get frequent system
  1100.                     messages:
  1101.  
  1102.                                  interact -input $user_spawn_id timeout 3600 return -output $spawn_id
  1103.  
  1104.  
  1105.                     If the pattern is the keyword nnnnuuuullllllll, and nulls are
  1106.                     allowed (via the rrrreeeemmmmoooovvvveeee____nnnnuuuullllllllssss command), the
  1107.                     corresponding body is executed if a single ASCII 0
  1108.                     is matched.  It is not possible to match 0 bytes
  1109.                     via glob or regexp patterns.
  1110.  
  1111.                     Prefacing a pattern with the flag ----iiiiwwwwrrrriiiitttteeee causes
  1112.                     the variable _i_n_t_e_r_a_c_t__o_u_t(_s_p_a_w_n__i_d) to be set to
  1113.                     the spawn_id which matched the pattern (or eof).
  1114.  
  1115.                     Actions such as bbbbrrrreeeeaaaakkkk and ccccoooonnnnttttiiiinnnnuuuueeee cause control
  1116.  
  1117.  
  1118.  
  1119.      Page 17                                         (printed 7/23/95)
  1120.  
  1121.  
  1122.  
  1123.  
  1124.  
  1125.  
  1126.      EEEEXXXXPPPPEEEECCCCTTTT((((1111))))       UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV ((((22229999 DDDDeeeecccceeeemmmmbbbbeeeerrrr 1111999999994444))))        EEEEXXXXPPPPEEEECCCCTTTT((((1111))))
  1127.  
  1128.  
  1129.  
  1130.                     structures (i.e., ffffoooorrrr, pppprrrroooocccc) to behave in the
  1131.                     usual way.  However rrrreeeettttuuuurrrrnnnn causes interact to
  1132.                     return to its caller, while iiiinnnntttteeeerrrr____rrrreeeettttuuuurrrrnnnn causes
  1133.                     iiiinnnntttteeeerrrraaaacccctttt to cause a return in its caller.  For
  1134.                     example, if "proc foo" called iiiinnnntttteeeerrrraaaacccctttt which then
  1135.                     executed the action iiiinnnntttteeeerrrr____rrrreeeettttuuuurrrrnnnn, pppprrrroooocccc ffffoooooooo would
  1136.                     return.  (This means that if iiiinnnntttteeeerrrraaaacccctttt calls
  1137.                     iiiinnnntttteeeerrrrpppprrrreeeetttteeeerrrr interactively typing rrrreeeettttuuuurrrrnnnn will cause
  1138.                     the interact to continue, while iiiinnnntttteeeerrrr____rrrreeeettttuuuurrrrnnnn will
  1139.                     cause the interact to return to its caller.)
  1140.  
  1141.                     During iiiinnnntttteeeerrrraaaacccctttt, raw mode is used so that all
  1142.                     characters may be passed to the current process.
  1143.                     If the current process does not catch job control
  1144.                     signals, it will stop if sent a stop signal (by
  1145.                     default ^Z).  To restart it, send a continue
  1146.                     signal (such as by "kill -CONT <pid>").  If you
  1147.                     really want to send a SIGSTOP to such a process
  1148.                     (by ^Z), consider spawning csh first and then
  1149.                     running your program.  On the other hand, if you
  1150.                     want to send a SIGSTOP to EEEExxxxppppeeeecccctttt itself, first
  1151.                     press the escape character, and then press ^Z.
  1152.  
  1153.                     String-body pairs can be used as a shorthand for
  1154.                     avoiding having to enter the interpreter and
  1155.                     execute commands interactively.  The previous
  1156.                     terminal mode is used while the body of a string-
  1157.                     body pair is being executed.
  1158.  
  1159.                     For speed, actions execute in raw mode by default.
  1160.                     The ----rrrreeeesssseeeetttt flag resets the terminal to the mode it
  1161.                     had before iiiinnnntttteeeerrrraaaacccctttt was executed (invariably,
  1162.                     cooked mode).  Note that characters entered when
  1163.                     the mode is being switched may be lost (an
  1164.                     unfortunate feature of the terminal driver on some
  1165.                     systems).  The only reason to use ----rrrreeeesssseeeetttt is if
  1166.                     your action depends on running in cooked mode.
  1167.  
  1168.                     The ----eeeecccchhhhoooo flag sends characters that match the
  1169.                     following pattern back to the process that
  1170.                     generated them as each character is read.  This
  1171.                     may be useful when the user needs to see feedback
  1172.                     from partially typed patterns.
  1173.  
  1174.                     If a pattern is being echoed but eventually fails
  1175.                     to match, the characters are sent to the spawned
  1176.                     process.  If the spawned process then echoes them,
  1177.                     the user will see the characters twice.  ----eeeecccchhhhoooo is
  1178.                     probably only appropriate in situations where the
  1179.                     user is unlikely to not complete the pattern.  For
  1180.                     example, the following excerpt is from rftp, the
  1181.                     recursive-ftp script, where the user is prompted
  1182.  
  1183.  
  1184.  
  1185.      Page 18                                         (printed 7/23/95)
  1186.  
  1187.  
  1188.  
  1189.  
  1190.  
  1191.  
  1192.      EEEEXXXXPPPPEEEECCCCTTTT((((1111))))       UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV ((((22229999 DDDDeeeecccceeeemmmmbbbbeeeerrrr 1111999999994444))))        EEEEXXXXPPPPEEEECCCCTTTT((((1111))))
  1193.  
  1194.  
  1195.  
  1196.                     to enter ~g, ~p, or ~l, to get, put, or list the
  1197.                     current directory recursively.  These are so far
  1198.                     away from the normal ftp commands, that the user
  1199.                     is unlikely to type ~ followed by anything else,
  1200.                     except mistakenly, in which case, they'll probably
  1201.                     just ignore the result anyway.
  1202.  
  1203.                         interact {
  1204.                                  -echo ~g {getcurdirectory 1}
  1205.                                  -echo ~l {getcurdirectory 0}
  1206.                                  -echo ~p {putcurdirectory}
  1207.                         }
  1208.  
  1209.                     The ----nnnnoooobbbbuuuuffffffffeeeerrrr flag sends characters that match the
  1210.                     following pattern on to the output process as
  1211.                     characters are read.
  1212.  
  1213.                     This is useful when you wish to let a program echo
  1214.                     back the pattern.  For example, the following
  1215.                     might be used to monitor where a person is dialing
  1216.                     (a Hayes-style modem).  Each time "atd" is seen
  1217.                     the script logs the rest of the line.
  1218.  
  1219.                         proc lognumber {} {
  1220.                             interact -nobuffer -re "(.*)" return
  1221.                             puts $log "[exec date]: dialed $interact_out(1,string)"
  1222.                         }
  1223.  
  1224.                         interact -nobuffer "atd" lognumber
  1225.  
  1226.  
  1227.                     During iiiinnnntttteeeerrrraaaacccctttt, previous use of lllloooogggg____uuuusssseeeerrrr is
  1228.                     ignored.  In particular, iiiinnnntttteeeerrrraaaacccctttt will force its
  1229.                     output to be logged (sent to the standard output)
  1230.                     since it is presumed the user doesn't wish to
  1231.                     interact blindly.
  1232.  
  1233.                     The ----oooo flag causes any following key-body pairs to
  1234.                     be applied to the output of the current process.
  1235.                     This can be useful, for example, when dealing with
  1236.                     hosts that send unwanted characters during a
  1237.                     telnet session.
  1238.  
  1239.                     By default, iiiinnnntttteeeerrrraaaacccctttt expects the user to be
  1240.                     writing stdin and reading stdout of the EEEExxxxppppeeeecccctttt
  1241.                     process itself.  The ----uuuu flag (for "user") makes
  1242.                     iiiinnnntttteeeerrrraaaacccctttt look for the user as the process named by
  1243.                     its argument (which must be a spawned id).
  1244.  
  1245.                     This allows two unrelated processes to be joined
  1246.                     together without using an explicit loop.  To aid
  1247.                     in debugging, Expect diagnostics always go to
  1248.  
  1249.  
  1250.  
  1251.      Page 19                                         (printed 7/23/95)
  1252.  
  1253.  
  1254.  
  1255.  
  1256.  
  1257.  
  1258.      EEEEXXXXPPPPEEEECCCCTTTT((((1111))))       UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV ((((22229999 DDDDeeeecccceeeemmmmbbbbeeeerrrr 1111999999994444))))        EEEEXXXXPPPPEEEECCCCTTTT((((1111))))
  1259.  
  1260.  
  1261.  
  1262.                     stderr (or stdout for certain logging and
  1263.                     debugging information).  For the same reason, the
  1264.                     iiiinnnntttteeeerrrrpppprrrreeeetttteeeerrrr command will read interactively from
  1265.                     stdin.
  1266.  
  1267.                     For example, the following fragment creates a
  1268.                     login process.  Then it dials the user (not
  1269.                     shown), and finally connects the two together.  Of
  1270.                     course, any process may be substituted for login.
  1271.                     A shell, for example, would allow the user to work
  1272.                     without supplying an account and password.
  1273.  
  1274.                         spawn login
  1275.                         set login $spawn_id
  1276.                         spawn tip modem
  1277.                         # dial back out to user
  1278.                         # connect user to login
  1279.                         interact -u $login
  1280.  
  1281.                     To send output to multiple processes, list each
  1282.                     spawn id list prefaced by a ----oooouuuuttttppppuuuutttt flag.  Input
  1283.                     for a group of output spawn ids may be determined
  1284.                     by a spawn id list prefaced by a ----iiiinnnnppppuuuutttt flag.
  1285.                     (Both ----iiiinnnnppppuuuutttt and ----oooouuuuttttppppuuuutttt may take lists in the
  1286.                     same form as the ----iiii flag in the eeeexxxxppppeeeecccctttt command,
  1287.                     except that any_spawn_id is not meaningful in
  1288.                     iiiinnnntttteeeerrrraaaacccctttt.) All following flags and strings (or
  1289.                     patterns) apply to this input until another -input
  1290.                     flag appears.  If no ----iiiinnnnppppuuuutttt appears, ----oooouuuuttttppppuuuutttt
  1291.                     implies "-input $user_spawn_id -output".
  1292.                     (Similarly, with patterns that do not have
  1293.                     ----iiiinnnnppppuuuutttt.) If one ----iiiinnnnppppuuuutttt is specified, it overrides
  1294.                     $user_spawn_id.  If a second ----iiiinnnnppppuuuutttt is specified,
  1295.                     it overrides $spawn_id.  Additional ----iiiinnnnppppuuuutttt flags
  1296.                     may be specified.
  1297.  
  1298.                     The two implied input processes default to having
  1299.                     their outputs specified as $spawn_id and
  1300.                     $user_spawn_id (in reverse). If a ----iiiinnnnppppuuuutttt flag
  1301.                     appears with no ----oooouuuuttttppppuuuutttt flag, characters from that
  1302.                     process are discarded.
  1303.  
  1304.                     The ----iiii flag introduces a replacement for the
  1305.                     current spawn_id when no other ----iiiinnnnppppuuuutttt or ----oooouuuuttttppppuuuutttt
  1306.                     flags are used.
  1307.  
  1308.                     It is possible to change the processes that are
  1309.                     being interacted with by using indirect spawn ids.
  1310.                     (Indirect spawn ids are described in the section
  1311.                     on the expect command.)  Indirect spawn ids may be
  1312.                     specified with the -i, -u, -input, or -output
  1313.                     flags.
  1314.  
  1315.  
  1316.  
  1317.      Page 20                                         (printed 7/23/95)
  1318.  
  1319.  
  1320.  
  1321.  
  1322.  
  1323.  
  1324.      EEEEXXXXPPPPEEEECCCCTTTT((((1111))))       UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV ((((22229999 DDDDeeeecccceeeemmmmbbbbeeeerrrr 1111999999994444))))        EEEEXXXXPPPPEEEECCCCTTTT((((1111))))
  1325.  
  1326.  
  1327.  
  1328.           eeeexxxxpppp____iiiinnnntttteeeerrrrnnnnaaaallll [-_f _f_i_l_e] _v_a_l_u_e
  1329.                     causes further commands to send diagnostic
  1330.                     information internal to EEEExxxxppppeeeecccctttt to stderr if _v_a_l_u_e
  1331.                     is non-zero.  This output is disabled if _v_a_l_u_e is
  1332.                     0.  The diagnostic information includes every
  1333.                     character received, and every attempt made to
  1334.                     match the current output against the patterns.
  1335.  
  1336.                     If the optional _f_i_l_e is supplied, all normal and
  1337.                     debugging output is written to that file
  1338.                     (regardless of the value of _v_a_l_u_e).  Any previous
  1339.                     diagnostic output file is closed.
  1340.  
  1341.                     The ----iiiinnnnffffoooo flag causes exp_internal to return a
  1342.                     description of the most recent non-info arguments
  1343.                     given.
  1344.  
  1345.           iiiinnnntttteeeerrrrpppprrrreeeetttteeeerrrr
  1346.                     causes the user to be interactively prompted for
  1347.                     EEEExxxxppppeeeecccctttt and Tcl commands.  The result of each
  1348.                     command is printed.
  1349.  
  1350.                     Actions such as bbbbrrrreeeeaaaakkkk and ccccoooonnnnttttiiiinnnnuuuueeee cause control
  1351.                     structures (i.e., ffffoooorrrr, pppprrrroooocccc) to behave in the
  1352.                     usual way.  However rrrreeeettttuuuurrrrnnnn causes interpreter to
  1353.                     return to its caller, while iiiinnnntttteeeerrrr____rrrreeeettttuuuurrrrnnnn causes
  1354.                     iiiinnnntttteeeerrrrpppprrrreeeetttteeeerrrr to cause a return in its caller.  For
  1355.                     example, if "proc foo" called iiiinnnntttteeeerrrrpppprrrreeeetttteeeerrrr which
  1356.                     then executed the action iiiinnnntttteeeerrrr____rrrreeeettttuuuurrrrnnnn, pppprrrroooocccc ffffoooooooo
  1357.                     would return.  Any other command causes
  1358.                     iiiinnnntttteeeerrrrpppprrrreeeetttteeeerrrr to continue prompting for new
  1359.                     commands.
  1360.  
  1361.                     By default, the prompt contains two integers.  The
  1362.                     first integer describes the depth of the
  1363.                     evaluation stack (i.e., how many times Tcl_Eval
  1364.                     has been called).  The second integer is the Tcl
  1365.                     history identifier.  The prompt can be set by
  1366.                     defining a procedure called "prompt1" whose return
  1367.                     value becomes the next prompt.  If a statement has
  1368.                     open quotes, parens, braces, or brackets, a
  1369.                     secondary prompt (by default "+> ") is issued upon
  1370.                     newline.  The secondary prompt may be set by
  1371.                     defining a procedure called "prompt2".
  1372.  
  1373.                     During iiiinnnntttteeeerrrrpppprrrreeeetttteeeerrrr, cooked mode is used, even if
  1374.                     the its caller was using raw mode.
  1375.  
  1376.           lllloooogggg____ffffiiiilllleeee [_a_r_g_s] [[-_a] _f_i_l_e]
  1377.                     If a filename is provided, lllloooogggg____ffffiiiilllleeee will record a
  1378.                     transcript of the session (beginning at that
  1379.                     point) in the file.  lllloooogggg____ffffiiiilllleeee will stop recording
  1380.  
  1381.  
  1382.  
  1383.      Page 21                                         (printed 7/23/95)
  1384.  
  1385.  
  1386.  
  1387.  
  1388.  
  1389.  
  1390.      EEEEXXXXPPPPEEEECCCCTTTT((((1111))))       UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV ((((22229999 DDDDeeeecccceeeemmmmbbbbeeeerrrr 1111999999994444))))        EEEEXXXXPPPPEEEECCCCTTTT((((1111))))
  1391.  
  1392.  
  1393.  
  1394.                     if no argument is given.  Any previous log file is
  1395.                     closed.
  1396.  
  1397.                     Instead of a filename, a Tcl file identifier may
  1398.                     be provided by using the ----ooooppppeeeennnn or ----lllleeeeaaaavvvveeeeooooppppeeeennnn
  1399.                     flags.  This is similar to the ssssppppaaaawwwwnnnn command.
  1400.                     (See ssssppppaaaawwwwnnnn for more info.)
  1401.  
  1402.                     The ----aaaa flag forces output to be logged that was
  1403.                     suppressed by the lllloooogggg____uuuusssseeeerrrr command.
  1404.  
  1405.                     By default, the lllloooogggg____ffffiiiilllleeee command _a_p_p_e_n_d_s to old
  1406.                     files rather than truncating them, for the
  1407.                     convenience of being able to turn logging off and
  1408.                     on multiple times in one session.  To truncate
  1409.                     files, use the ----nnnnooooaaaappppppppeeeennnndddd ffffllllaaaagggg....
  1410.  
  1411.                     The ----iiiinnnnffffoooo flag causes log_file to return a
  1412.                     description of the most recent non-info arguments
  1413.                     given.
  1414.  
  1415.           lllloooogggg____uuuusssseeeerrrr _0|_1
  1416.                     By default, the send/expect dialogue is logged to
  1417.                     stdout (and a logfile if open).  The logging to
  1418.                     stdout is disabled by the command "log_user 0" and
  1419.                     reenabled by "log_user 1".  Logging to the logfile
  1420.                     is unchanged.
  1421.  
  1422.                     The ----iiiinnnnffffoooo flag causes log_user to return a
  1423.                     description of the most recent non-info arguments
  1424.                     given.
  1425.  
  1426.  
  1427.           mmmmaaaattttcccchhhh____mmmmaaaaxxxx [-_d] [-_i _s_p_a_w_n__i_d] [_s_i_z_e]
  1428.                     defines the size of the buffer (in bytes) used
  1429.                     internally by eeeexxxxppppeeeecccctttt.  With no _s_i_z_e argument, the
  1430.                     current size is returned.
  1431.  
  1432.                     With the ----dddd flag, the default size is set.  (The
  1433.                     initial default is 2000.) With the ----iiii flag, the
  1434.                     size is set for the named spawn id, otherwise it
  1435.                     is set for the current process.
  1436.  
  1437.           oooovvvveeeerrrrllllaaaayyyy [-# _s_p_a_w_n__i_d] [-# _s_p_a_w_n__i_d] [...] _p_r_o_g_r_a_m [_a_r_g_s]
  1438.                     executes _p_r_o_g_r_a_m _a_r_g_s in place of the current
  1439.                     EEEExxxxppppeeeecccctttt program, which terminates.  A bare hyphen
  1440.                     argument forces a hyphen in front of the command
  1441.                     name as if it was a login shell.  All spawn_ids
  1442.                     are closed except for those named as arguments.
  1443.                     These are mapped onto the named file identifiers.
  1444.  
  1445.                     Spawn_ids are mapped to file identifiers for the
  1446.  
  1447.  
  1448.  
  1449.      Page 22                                         (printed 7/23/95)
  1450.  
  1451.  
  1452.  
  1453.  
  1454.  
  1455.  
  1456.      EEEEXXXXPPPPEEEECCCCTTTT((((1111))))       UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV ((((22229999 DDDDeeeecccceeeemmmmbbbbeeeerrrr 1111999999994444))))        EEEEXXXXPPPPEEEECCCCTTTT((((1111))))
  1457.  
  1458.  
  1459.  
  1460.                     new program to inherit.  For example, the
  1461.                     following line runs chess and allows it to be
  1462.                     controlled by the current process - say, a chess
  1463.                     master.
  1464.  
  1465.                                  overlay -0 $spawn_id -1 $spawn_id -2 $spawn_id chess
  1466.  
  1467.                     This is more efficient than "interact -u",
  1468.                     however, it sacrifices the ability to do
  1469.                     programmed interaction since the EEEExxxxppppeeeecccctttt process is
  1470.                     no longer in control.
  1471.  
  1472.                     Note that no controlling terminal is provided.
  1473.                     Thus, if you disconnect or remap standard input,
  1474.                     programs that do job control (shells, login, etc)
  1475.                     will not function properly.
  1476.  
  1477.           ppppaaaarrrriiiittttyyyy [-_d] [-_i _s_p_a_w_n__i_d] [_v_a_l_u_e]
  1478.                     defines whether parity should be retained or
  1479.                     stripped from the output of spawned processes.  If
  1480.                     _v_a_l_u_e is zero, parity is stripped, otherwise it is
  1481.                     not stripped.  With no _v_a_l_u_e argument, the current
  1482.                     value is returned.
  1483.  
  1484.                     With the ----dddd flag, the default parity value is set.
  1485.                     (The initial default is 1, i.e., parity is not
  1486.                     stripped.) With the ----iiii flag, the parity value is
  1487.                     set for the named spawn id, otherwise it is set
  1488.                     for the current process.
  1489.  
  1490.           eeeexxxxpppp____ppppiiiidddd [-_i _s_p_a_w_n__i_d]
  1491.                     returns the process id corresponding to the
  1492.                     current spawn id or the named spawn id.
  1493.  
  1494.           rrrreeeemmmmoooovvvveeee____nnnnuuuullllllllssss [-_d] [-_i _s_p_a_w_n__i_d] [_v_a_l_u_e]
  1495.                     defines whether nulls are retained or removed from
  1496.                     the output of spawned processes before pattern
  1497.                     matching or storing in the variable _e_x_p_e_c_t__o_u_t or
  1498.                     _i_n_t_e_r_a_c_t__o_u_t.  If _v_a_l_u_e is 1, nulls are removed.
  1499.                     If _v_a_l_u_e is 0, nulls are not removed.  With no
  1500.                     _v_a_l_u_e argument, the current value is returned.
  1501.  
  1502.                     With the ----dddd flag, the default value is set.  (The
  1503.                     initial default is 1, i.e., nulls are removed.)
  1504.                     With the ----iiii flag, the value is set for the named
  1505.                     spawn id, otherwise it is set for the current
  1506.                     process.
  1507.  
  1508.                     Whether or not nulls are removed, EEEExxxxppppeeeecccctttt will
  1509.                     record null bytes to the log and stdout.
  1510.  
  1511.           sssseeeennnndddd [-_f_l_a_g_s] _s_t_r_i_n_g
  1512.  
  1513.  
  1514.  
  1515.      Page 23                                         (printed 7/23/95)
  1516.  
  1517.  
  1518.  
  1519.  
  1520.  
  1521.  
  1522.      EEEEXXXXPPPPEEEECCCCTTTT((((1111))))       UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV ((((22229999 DDDDeeeecccceeeemmmmbbbbeeeerrrr 1111999999994444))))        EEEEXXXXPPPPEEEECCCCTTTT((((1111))))
  1523.  
  1524.  
  1525.  
  1526.                     Sends _s_t_r_i_n_g to the current process.  For example,
  1527.                     the command
  1528.  
  1529.                                  send "hello world\r"
  1530.  
  1531.                     sends the characters, h e l l o <blank> w o r l d
  1532.                     <return> to the current process. (Tcl includes a
  1533.                     printf-like command (called ffffoooorrrrmmmmaaaatttt) which can
  1534.                     build arbitrarily complex strings.)
  1535.  
  1536.                     Characters are sent immediately although programs
  1537.                     with line-buffered input will not read the
  1538.                     characters until a return character is sent.  A
  1539.                     return character is denoted "\r".
  1540.  
  1541.                     The -------- flag forces the next argument to be
  1542.                     interpreted as a string rather than a flag.  Any
  1543.                     string can be preceded by "--" whether or not it
  1544.                     actually looks like a flag.  This provides a
  1545.                     reliable mechanism to specify variable strings
  1546.                     without being tripped up by those that
  1547.                     accidentally look like flags.  (All strings
  1548.                     starting with "-" are reserved for future
  1549.                     options.)
  1550.  
  1551.                     The ----iiii flag declares that the string be sent to
  1552.                     the named spawn_id.  If the spawn_id is
  1553.                     _u_s_e_r__s_p_a_w_n__i_d, and the terminal is in raw mode,
  1554.                     newlines in the string are translated to return-
  1555.                     newline sequences so that they appear as it the
  1556.                     terminal was in cooked mode.  The ----rrrraaaawwww flag
  1557.                     disables this translation.
  1558.  
  1559.                     The ----nnnnuuuullllllll flag sends null characters (0 bytes).
  1560.                     By default, one null is sent.  An integer may
  1561.                     follow the ----0000 to indicate how many nulls to send.
  1562.  
  1563.                     The ----bbbbrrrreeeeaaaakkkk flag generates a break condition.  This
  1564.                     only makes sense if the spawn id refers to a tty
  1565.                     device opened via "spawn -open".  If you have
  1566.                     spawned a process such as tip, you should use
  1567.                     tip's convention for generating a break.
  1568.  
  1569.                     The ----ssss flag forces output to be sent "slowly",
  1570.                     thus avoid the common situation where a computer
  1571.                     outtypes an input buffer that was designed for a
  1572.                     human who would never outtype the same buffer.
  1573.                     This output is controlled by the value of the
  1574.                     variable "send_slow" which takes a two element
  1575.                     list.  The first element is an integer that
  1576.                     describes the number of bytes to send atomically.
  1577.                     The second element is a real number that describes
  1578.  
  1579.  
  1580.  
  1581.      Page 24                                         (printed 7/23/95)
  1582.  
  1583.  
  1584.  
  1585.  
  1586.  
  1587.  
  1588.      EEEEXXXXPPPPEEEECCCCTTTT((((1111))))       UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV ((((22229999 DDDDeeeecccceeeemmmmbbbbeeeerrrr 1111999999994444))))        EEEEXXXXPPPPEEEECCCCTTTT((((1111))))
  1589.  
  1590.  
  1591.  
  1592.                     the number of seconds by which the atomic sends
  1593.                     must be separated.  For example, "set send_slow
  1594.                     {10 .001}" would force "send -s" to send strings
  1595.                     with 1 millisecond in between each 10 characters
  1596.                     sent.
  1597.  
  1598.                     The ----hhhh flag forces output to be sent (somewhat)
  1599.                     like a human actually typing.  Human-like delays
  1600.                     appear between the characters.  (The algorithm is
  1601.                     based upon a Weibull distribution, with
  1602.                     modifications to suit this particular
  1603.                     application.)  This output is controlled by the
  1604.                     value of the variable "send_human" which takes a
  1605.                     five element list.  The first two elements are
  1606.                     average interarrival time of characters in
  1607.                     seconds.  The first is used by default.  The
  1608.                     second is used at word endings, to simulate the
  1609.                     subtle pauses that occasionally occur at such
  1610.                     transitions.  The third parameter is a measure of
  1611.                     varibility where .1 is quite variable, 1 is
  1612.                     reasonably variable, and 10 is quite invariable.
  1613.                     The extremes are 0 to infinity.  The last two
  1614.                     parameters are, respectively, a minimum and
  1615.                     maximum interarrival time.  The minimum and
  1616.                     maximum are used last and "clip" the final time.
  1617.                     The ultimate average can be quite different from
  1618.                     the given average if the minimum and miximum clip
  1619.                     enough values.
  1620.  
  1621.                     As an example, the following command emulates a
  1622.                     fast and consistent typist:
  1623.  
  1624.                                  set send_human {.1 .3 1 .05 2}
  1625.                                  send -h "I'm hungry.  Let's do lunch."
  1626.  
  1627.                     while the following might be more suitable after a
  1628.                     hangover:
  1629.  
  1630.                                  set send_human {.4 .4 .2 .5 100}
  1631.                                  send -h "Goodd party lash night!"
  1632.  
  1633.                     Note that errors are not simulated, although you
  1634.                     can set up error correction situations yourself by
  1635.                     embedding mistakes and corrections in a send
  1636.                     argument.
  1637.  
  1638.                     It is a good idea to precede the first sssseeeennnndddd to a
  1639.                     process by an eeeexxxxppppeeeecccctttt.  eeeexxxxppppeeeecccctttt will wait for the
  1640.                     process to start, while sssseeeennnndddd cannot.  In
  1641.                     particular, if the first sssseeeennnndddd completes before the
  1642.                     process starts running, you run the risk of having
  1643.                     your data ignored.  In situations where
  1644.  
  1645.  
  1646.  
  1647.      Page 25                                         (printed 7/23/95)
  1648.  
  1649.  
  1650.  
  1651.  
  1652.  
  1653.  
  1654.      EEEEXXXXPPPPEEEECCCCTTTT((((1111))))       UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV ((((22229999 DDDDeeeecccceeeemmmmbbbbeeeerrrr 1111999999994444))))        EEEEXXXXPPPPEEEECCCCTTTT((((1111))))
  1655.  
  1656.  
  1657.  
  1658.                     interactive programs offer no initial prompt, you
  1659.                     can precede sssseeeennnndddd by a delay as in:
  1660.  
  1661.                                  # To avoid giving hackers hints on how to break in,
  1662.                                  # this system does not prompt for an external password.
  1663.                                  # Wait for 5 seconds for exec to complete
  1664.                                  spawn telnet very.secure.gov
  1665.                                  sleep 5
  1666.                                  send password\r
  1667.  
  1668.                     eeeexxxxpppp____sssseeeennnndddd is an alias for sssseeeennnndddd.  If you are using
  1669.                     Expectk or some other variant of Expect in the Tk
  1670.                     environment, sssseeeennnndddd is defined by Tk for an entirely
  1671.                     different purpose.  eeeexxxxpppp____sssseeeennnndddd is provided for
  1672.                     compatibility between environments.  Similar
  1673.                     aliases are provided for other Expect's other send
  1674.                     commands.
  1675.  
  1676.           sssseeeennnndddd____eeeerrrrrrrroooorrrr _s_t_r_i_n_g
  1677.                     is like sssseeeennnndddd, except that the string is sent to
  1678.                     stderr rather than the current process.
  1679.  
  1680.           sssseeeennnndddd____lllloooogggg _s_t_r_i_n_g
  1681.                     is like sssseeeennnndddd, except that the string is only sent
  1682.                     to the log file (see lllloooogggg____ffffiiiilllleeee.) The arguments are
  1683.                     ignored if no log file is open.
  1684.  
  1685.           sssseeeennnndddd____ttttttttyyyy _s_t_r_i_n_g
  1686.                     is like sssseeeennnndddd, except that the string is sent to
  1687.                     /dev/tty rather than the current process.
  1688.  
  1689.           sssseeeennnndddd____uuuusssseeeerrrr [_a_r_g_s] _s_t_r_i_n_g
  1690.                     is like sssseeeennnndddd, except that the arguments are sent
  1691.                     to stdout rather than the current process.
  1692.  
  1693.           sssslllleeeeeeeepppp_s_e_c_o_n_d_s
  1694.                     causes the script to sleep for the given number of
  1695.                     seconds.  Seconds may be a decimal number.
  1696.                     Interrupts (and Tk events if you are using
  1697.                     Expectk) are processed while Expect sleeps.
  1698.  
  1699.           ssssppppaaaawwwwnnnn [_a_r_g_s] _p_r_o_g_r_a_m [_a_r_g_s]
  1700.                     creates a new process running _p_r_o_g_r_a_m _a_r_g_s.  Its
  1701.                     stdin, stdout and stderr are connected to Expect,
  1702.                     so that they may be read and written by other
  1703.                     EEEExxxxppppeeeecccctttt commands.  The connection is broken by
  1704.                     cccclllloooosssseeee or if the process itself closes any of the
  1705.                     file identifiers.
  1706.  
  1707.                     When a process is started by ssssppppaaaawwwwnnnn, the variable
  1708.                     _s_p_a_w_n__i_d is set to a descriptor referring to that
  1709.                     process.  The process described by _s_p_a_w_n__i_d is
  1710.  
  1711.  
  1712.  
  1713.      Page 26                                         (printed 7/23/95)
  1714.  
  1715.  
  1716.  
  1717.  
  1718.  
  1719.  
  1720.      EEEEXXXXPPPPEEEECCCCTTTT((((1111))))       UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV ((((22229999 DDDDeeeecccceeeemmmmbbbbeeeerrrr 1111999999994444))))        EEEEXXXXPPPPEEEECCCCTTTT((((1111))))
  1721.  
  1722.  
  1723.  
  1724.                     considered the _c_u_r_r_e_n_t _p_r_o_c_e_s_s.  _s_p_a_w_n__i_d may be
  1725.                     read or written, in effect providing job control.
  1726.  
  1727.                     _u_s_e_r__s_p_a_w_n__i_d is a global variable containing a
  1728.                     descriptor which refers to the user.  For example,
  1729.                     when _s_p_a_w_n__i_d is set to this value, eeeexxxxppppeeeecccctttt behaves
  1730.                     like eeeexxxxppppeeeecccctttt____uuuusssseeeerrrr.
  1731.  
  1732.                     _e_r_r_o_r__s_p_a_w_n__i_d is a global variable containing a
  1733.                     descriptor which refers to the standard error.
  1734.                     For example, when _s_p_a_w_n__i_d is set to this value,
  1735.                     sssseeeennnndddd behaves like sssseeeennnndddd____eeeerrrrrrrroooorrrr.
  1736.  
  1737.  
  1738.                     _t_t_y__s_p_a_w_n__i_d is a global variable containing a
  1739.                     descriptor which refers to /dev/tty.  If /dev/tty
  1740.                     does not exist (such as in a cron, at, or batch
  1741.                     script), then _t_t_y__s_p_a_w_n__i_d is not defined.  This
  1742.                     may be tested as:
  1743.  
  1744.                                  if [info vars tty_spawn_id] {
  1745.                                          # /dev/tty exists
  1746.                                  } else {
  1747.                                          # /dev/tty doesn't exist
  1748.                                          # probably in cron, batch, or at script
  1749.                                  }
  1750.  
  1751.  
  1752.                     ssssppppaaaawwwwnnnn returns the UNIX process id.  If no process
  1753.                     is spawned, 0 is returned.  The variable
  1754.                     _s_p_a_w_n__o_u_t(_s_l_a_v_e,_n_a_m_e) is set to the name of the
  1755.                     pty slave device.
  1756.  
  1757.  
  1758.                     By default, ssssppppaaaawwwwnnnn echoes the command name and
  1759.                     arguments.  The ----nnnnooooeeeecccchhhhoooo flag stops ssssppppaaaawwwwnnnn from
  1760.                     doing this.
  1761.  
  1762.                     The ----ccccoooonnnnssssoooolllleeee flag causes console output to be
  1763.                     redirected to the spawned process.  This is not
  1764.                     supported on all systems.
  1765.  
  1766.                     Internally, ssssppppaaaawwwwnnnn uses a pty, initialized the same
  1767.                     way as the user's tty.  This is further
  1768.                     initialized so that all settings are "sane"
  1769.                     (according to stty(1)).  If the variable _s_t_t_y__i_n_i_t
  1770.                     is defined, it is interpreted in the style of stty
  1771.                     arguments as further configuration.  For example,
  1772.                     "set stty_init raw" will cause further spawned
  1773.                     processes's terminals to start in raw mode.
  1774.                     ----nnnnoooottttttttyyyyccccooooppppyyyy skips the initialization based on the
  1775.                     user's tty.  ----nnnnoooottttttttyyyyiiiinnnniiiitttt skips the "sane"
  1776.  
  1777.  
  1778.  
  1779.      Page 27                                         (printed 7/23/95)
  1780.  
  1781.  
  1782.  
  1783.  
  1784.  
  1785.  
  1786.      EEEEXXXXPPPPEEEECCCCTTTT((((1111))))       UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV ((((22229999 DDDDeeeecccceeeemmmmbbbbeeeerrrr 1111999999994444))))        EEEEXXXXPPPPEEEECCCCTTTT((((1111))))
  1787.  
  1788.  
  1789.  
  1790.                     initialization.
  1791.  
  1792.                     Normally, ssssppppaaaawwwwnnnn takes little time to execute.  If
  1793.                     you notice spawn taking a significant amount of
  1794.                     time, it is probably encountering ptys that are
  1795.                     wedged.  A number of tests are run on ptys to
  1796.                     avoid entanglements with errant processes.  (These
  1797.                     take 10 seconds per wedged pty.)  Running Expect
  1798.                     with the ----dddd option will show if EEEExxxxppppeeeecccctttt is
  1799.                     encountering many ptys in odd states.  If you
  1800.                     cannot kill the processes to which these ptys are
  1801.                     attached, your only recourse may be to reboot.
  1802.  
  1803.                     If _p_r_o_g_r_a_m cannot be spawned successfully because
  1804.                     exec(2) fails (e.g. when _p_r_o_g_r_a_m doesn't exist),
  1805.                     an error message will be returned by the next
  1806.                     iiiinnnntttteeeerrrraaaacccctttt or eeeexxxxppppeeeecccctttt command as if _p_r_o_g_r_a_m had run
  1807.                     and produced the error message as output.  This
  1808.                     behavior is a natural consequence of the
  1809.                     implementation of ssssppppaaaawwwwnnnn.  Internally, spawn forks,
  1810.                     after which the spawned process has no way to
  1811.                     communicate with the original EEEExxxxppppeeeecccctttt process
  1812.                     except by communication via the spawn_id.
  1813.  
  1814.                     The ----ooooppppeeeennnn flag causes the next argument to be
  1815.                     interpreted as a Tcl file identifier (i.e.,
  1816.                     returned by ooooppppeeeennnn.) The spawn id can then be used
  1817.                     as if it were a spawned process.  (The file
  1818.                     identifier should no longer be used.) This lets
  1819.                     you treat raw devices, files, and pipelines as
  1820.                     spawned processes without using a pty.  0 is
  1821.                     returned to indicate there is no associated
  1822.                     process.  When the connection to the spawned
  1823.                     process is closed, so is the Tcl file identifier.
  1824.                     The ----lllleeeeaaaavvvveeeeooooppppeeeennnn flag is similar to ----ooooppppeeeennnn except
  1825.                     that ----lllleeeeaaaavvvveeeeooooppppeeeennnn causes the file identifier to be
  1826.                     left open even after the spawn id is closed.
  1827.  
  1828.                     The ----ppppttttyyyy flag causes a pty to be opened but no
  1829.                     process spawned.  0 is returned to indicate there
  1830.                     is no associated process.  Spawn_id is set as
  1831.                     usual.
  1832.  
  1833.                     The variable _s_p_a_w_n__o_u_t(_s_l_a_v_e,_f_d) is set to a file
  1834.                     identifier corresponding to the pty slave.  It can
  1835.                     be closed using "close -slave".
  1836.  
  1837.                     The ----iiiiggggnnnnoooorrrreeee flag names a signal to be ignored in
  1838.                     the spawned process.  Otherwise, signals get the
  1839.                     default behavior.  Signals are named as in the
  1840.                     ttttrrrraaaapppp command, except that each signal requires a
  1841.                     separate flag.
  1842.  
  1843.  
  1844.  
  1845.      Page 28                                         (printed 7/23/95)
  1846.  
  1847.  
  1848.  
  1849.  
  1850.  
  1851.  
  1852.      EEEEXXXXPPPPEEEECCCCTTTT((((1111))))       UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV ((((22229999 DDDDeeeecccceeeemmmmbbbbeeeerrrr 1111999999994444))))        EEEEXXXXPPPPEEEECCCCTTTT((((1111))))
  1853.  
  1854.  
  1855.  
  1856.           ssssttttrrrraaaacccceeee _l_e_v_e_l
  1857.                     causes following statements to be printed before
  1858.                     being executed.  (Tcl's trace command traces
  1859.                     variables.) _l_e_v_e_l indicates how far down in the
  1860.                     call stack to trace.  For example, the following
  1861.                     command runs EEEExxxxppppeeeecccctttt while tracing the first 4
  1862.                     levels of calls, but none below that.
  1863.  
  1864.                                  expect -c "strace 4" script.exp
  1865.  
  1866.  
  1867.                     The ----iiiinnnnffffoooo flag causes strace to return a
  1868.                     description of the most recent non-info arguments
  1869.                     given.
  1870.  
  1871.           ssssttttttttyyyy _a_r_g_s changes terminal modes similarly to the external
  1872.                     stty command.
  1873.  
  1874.                     By default, the controlling terminal is accessed.
  1875.                     Other terminals can be accessed by appending "<
  1876.                     /dev/tty..." to the command.  (Note that the
  1877.                     arguments should not be grouped into a single
  1878.                     argument.)
  1879.  
  1880.                     Requests for status return it as the result of the
  1881.                     command.  If no status is requested and the
  1882.                     controlling terminal is accessed, the previous
  1883.                     status of the raw and echo attributes are returned
  1884.                     in a form which can later be used by the command.
  1885.  
  1886.                     For example, the arguments rrrraaaawwww or ----ccccooooooookkkkeeeedddd put the
  1887.                     terminal into raw mode.  The arguments ----rrrraaaawwww or
  1888.                     ccccooooooookkkkeeeedddd put the terminal into cooked mode.  The
  1889.                     arguments eeeecccchhhhoooo and ----eeeecccchhhhoooo put the terminal into
  1890.                     echo and noecho mode respectively.
  1891.  
  1892.                     The following example illustrates how to
  1893.                     temporarily disable echoing.  This could be used
  1894.                     in otherwise-automatic scripts to avoid embedding
  1895.                     passwords in them.  (See more discussion on this
  1896.                     under EXPECT HINTS below.)
  1897.  
  1898.                                  stty -echo
  1899.                                  send_user "Password: "
  1900.                                  expect_user -re "(.*)\n"
  1901.                                  set password $expect_out(1,string)
  1902.                                  stty echo
  1903.  
  1904.  
  1905.           ssssyyyysssstttteeeemmmm _a_r_g_s
  1906.                     gives _a_r_g_s to sh(1) as input, just as if it had
  1907.                     been typed as a command from a terminal.  EEEExxxxppppeeeecccctttt
  1908.  
  1909.  
  1910.  
  1911.      Page 29                                         (printed 7/23/95)
  1912.  
  1913.  
  1914.  
  1915.  
  1916.  
  1917.  
  1918.      EEEEXXXXPPPPEEEECCCCTTTT((((1111))))       UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV ((((22229999 DDDDeeeecccceeeemmmmbbbbeeeerrrr 1111999999994444))))        EEEEXXXXPPPPEEEECCCCTTTT((((1111))))
  1919.  
  1920.  
  1921.  
  1922.                     waits until the shell terminates.  The return
  1923.                     status from sh is handled the same way that eeeexxxxeeeecccc
  1924.                     handles its return status.
  1925.  
  1926.                     In contrast to eeeexxxxeeeecccc which redirects stdin and
  1927.                     stdout to the script, ssssyyyysssstttteeeemmmm performs no
  1928.                     redirection (other than that indicated by the
  1929.                     string itself).  Thus, it is possible to use
  1930.                     programs which must talk directly to /dev/tty.
  1931.                     For the same reason, the results of ssssyyyysssstttteeeemmmm are not
  1932.                     recorded in the log.
  1933.  
  1934.           ttttiiiimmmmeeeessssttttaaaammmmpppp [_a_r_g_s]
  1935.                     returns a timestamp.  With no arguments, the
  1936.                     number of seconds since the epoch is returned.
  1937.  
  1938.                     The ----ffffoooorrrrmmmmaaaatttt flag introduces a string which is
  1939.                     returned but with substitutions made according to
  1940.                     the POSIX rules for strftime.  For example %a is
  1941.                     replaced by an abbreviated weekday name (i.e.,
  1942.                     Sat).  Others are:
  1943.                                  %a      abbreviated weekday name
  1944.                                  %A      full weekday name
  1945.                                  %b      abbreviated month name
  1946.                                  %B      full month name
  1947.                                  %c      date-time as in: Wed Oct  6 11:45:56 1993
  1948.                                  %d      day of the month (01-31)
  1949.                                  %H      hour (00-23)
  1950.                                  %I      hour (01-12)
  1951.                                  %j      day (001-366)
  1952.                                  %m      month (01-12)
  1953.                                  %M      minute (00-59)
  1954.                                  %p      am or pm
  1955.                                  %S      second (00-61)
  1956.                                  %u      day (1-7, Monday is first day of week)
  1957.                                  %U      week (00-53, first Sunday is first day of week one)
  1958.                                  %V      week (01-53, ISO 8601 style)
  1959.                                  %w      day (0-6)
  1960.                                  %W      week (00-53, first Monday is first day of week one)
  1961.                                  %x      date-time as in: Wed Oct  6 1993
  1962.                                  %X      time as in: 23:59:59
  1963.                                  %y      year (00-99)
  1964.                                  %Y      year as in: 1993
  1965.                                  %Z      timezone (or nothing if not determinable)
  1966.                                  %%      a bare percent sign
  1967.  
  1968.                     Other % specifications are undefined.  Other
  1969.                     characters will be passed through untouched.  Only
  1970.                     the C locale is supported.
  1971.  
  1972.                     The ----sssseeeeccccoooonnnnddddssss flag introduces a number of seconds
  1973.                     since the epoch to be used as a source from which
  1974.  
  1975.  
  1976.  
  1977.      Page 30                                         (printed 7/23/95)
  1978.  
  1979.  
  1980.  
  1981.  
  1982.  
  1983.  
  1984.      EEEEXXXXPPPPEEEECCCCTTTT((((1111))))       UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV ((((22229999 DDDDeeeecccceeeemmmmbbbbeeeerrrr 1111999999994444))))        EEEEXXXXPPPPEEEECCCCTTTT((((1111))))
  1985.  
  1986.  
  1987.  
  1988.                     to format.  Otherwise, the current time is used.
  1989.  
  1990.                     The ----ggggmmmmtttt flag forces timestamp output to use the
  1991.                     GMT timezone.  With no flag, the local timezone is
  1992.                     used.
  1993.  
  1994.  
  1995.           ttttrrrraaaapppp [[_c_o_m_m_a_n_d] _s_i_g_n_a_l_s]
  1996.                     causes the given _c_o_m_m_a_n_d to be executed upon
  1997.                     future receipt of any of the given signals.  The
  1998.                     command is executed in the global scope.  If
  1999.                     _c_o_m_m_a_n_d is absent, the signal action is returned.
  2000.                     If _c_o_m_m_a_n_d is the string SIG_IGN, the signals are
  2001.                     ignored.  If _c_o_m_m_a_n_d is the string SIG_DFL, the
  2002.                     signals are result to the system default.  _s_i_g_n_a_l_s
  2003.                     is either a single signal or a list of signals.
  2004.                     Signals may be specified numerically or
  2005.                     symbolically as per signal(3).  The "SIG" prefix
  2006.                     may be omitted.
  2007.  
  2008.                     With no arguments (or the argument -number), ttttrrrraaaapppp
  2009.                     returns the signal number of the trap command
  2010.                     currently being executed.
  2011.  
  2012.                     The ----ccccooooddddeeee flag uses the return code of the command
  2013.                     in place of whatever code Tcl was about to return
  2014.                     when the command originally started running.
  2015.  
  2016.                     The ----iiiinnnntttteeeerrrrpppp flag causes the command to be
  2017.                     evaluated using the interpreter active at the time
  2018.                     the command started running rather than when the
  2019.                     trap was declared.
  2020.  
  2021.                     The ----nnnnaaaammmmeeee flag causes the ttttrrrraaaapppp command to return
  2022.                     the signal name of the trap command currently
  2023.                     being executed.
  2024.  
  2025.                     The ----mmmmaaaaxxxx flag causes the ttttrrrraaaapppp command to return
  2026.                     the largest signal number that can be set.
  2027.  
  2028.                     For example, the command "trap {send_user "Ouch!"}
  2029.                     SIGINT" will print "Ouch!" each time the user
  2030.                     presses ^C.
  2031.  
  2032.                     By default, SIGINT (which can usually be generated
  2033.                     by pressing ^C) and SIGTERM cause Expect to exit.
  2034.                     This is due to the following trap, created by
  2035.                     default when Expect starts.
  2036.  
  2037.                                  trap exit {SIGINT SIGTERM}
  2038.  
  2039.                     If you use the -D flag to start the debugger,
  2040.  
  2041.  
  2042.  
  2043.      Page 31                                         (printed 7/23/95)
  2044.  
  2045.  
  2046.  
  2047.  
  2048.  
  2049.  
  2050.      EEEEXXXXPPPPEEEECCCCTTTT((((1111))))       UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV ((((22229999 DDDDeeeecccceeeemmmmbbbbeeeerrrr 1111999999994444))))        EEEEXXXXPPPPEEEECCCCTTTT((((1111))))
  2051.  
  2052.  
  2053.  
  2054.                     SIGINT is redefined to start the interactive
  2055.                     debugger.  This is due to the following trap:
  2056.  
  2057.                                  trap {exp_debug 1} SIGINT
  2058.  
  2059.                     The debugger trap can be changed by setting the
  2060.                     environment variable EXPECT_DEBUG_INIT to a new
  2061.                     trap command.
  2062.  
  2063.                     You can, of course, override both of these just by
  2064.                     adding trap commands to your script.  In
  2065.                     particular, if you have your own "trap exit
  2066.                     SIGINT", this will override the debugger trap.
  2067.                     This is useful if you want to prevent users from
  2068.                     getting to the debugger at all.
  2069.  
  2070.                     If you want to define your own trap on SIGINT but
  2071.                     still trap to the debugger when it is running,
  2072.                     use:
  2073.  
  2074.                                  if ![exp_debug] {trap mystuff SIGINT}
  2075.  
  2076.                     Alternatively, you can trap to the debugger using
  2077.                     some other signal.
  2078.  
  2079.                     ttttrrrraaaapppp will not let you override the action for
  2080.                     SIGALRM as this is used internally to EEEExxxxppppeeeecccctttt.  The
  2081.                     disconnect command sets SIGALRM to SIG_IGN
  2082.                     (ignore).  You can reenable this as long as you
  2083.                     disable it during subsequent spawn commands.
  2084.  
  2085.                     See signal(3) for more info.
  2086.  
  2087.           wwwwaaaaiiiitttt [_a_r_g_s]
  2088.                     delays until a spawned process (or the current
  2089.                     process if none is named) terminates.
  2090.  
  2091.                     wwwwaaaaiiiitttt normally returns a list of four integers.
  2092.                     The first integer is the pid of the process that
  2093.                     was waited upon.  The second integer is the
  2094.                     corresponding spawn id.  The third integer is -1
  2095.                     if an operating system error occurred, or 0
  2096.                     otherwise.  If the third integer was 0, the fourth
  2097.                     integer is the status returned by the spawned
  2098.                     process.  If the third integer was -1, the fourth
  2099.                     integer is the value of errno set by the operating
  2100.                     system.  The global variable errorCode is also
  2101.                     set.
  2102.  
  2103.                     Additional elements may appear at the end of the
  2104.                     return value from wwwwaaaaiiiitttt.  An optional fifth element
  2105.                     identifies a class of information.  Currently, the
  2106.  
  2107.  
  2108.  
  2109.      Page 32                                         (printed 7/23/95)
  2110.  
  2111.  
  2112.  
  2113.  
  2114.  
  2115.  
  2116.      EEEEXXXXPPPPEEEECCCCTTTT((((1111))))       UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV ((((22229999 DDDDeeeecccceeeemmmmbbbbeeeerrrr 1111999999994444))))        EEEEXXXXPPPPEEEECCCCTTTT((((1111))))
  2117.  
  2118.  
  2119.  
  2120.                     only possible value for this element is
  2121.                     CHILDKILLED in which case the next two values are
  2122.                     the C-style signal name and a short textual
  2123.                     description.
  2124.  
  2125.                     The ----iiii flag declares the process to wait
  2126.                     corresponding to the named spawn_id (NOT the
  2127.                     process id).  It is possible to wait for any
  2128.                     spawned process by using the spawn id -1.
  2129.  
  2130.                     The ----nnnnoooowwwwaaaaiiiitttt flag causes the wait to return
  2131.                     immediately with the indication of a successful
  2132.                     wait.  When the process exits (later), it will
  2133.                     automatically disappear without the need for an
  2134.                     explicit wait.
  2135.  
  2136.      LLLLIIIIBBBBRRRRAAAARRRRIIIIEEEESSSS
  2137.           Expect automatically knows about two built-in libraries for
  2138.           Expect scripts.  These are defined by the directories named
  2139.           in the variables exp_library and exp_exec_library.  Both are
  2140.           meant to contain utility files that can be used by other
  2141.           scripts.
  2142.  
  2143.           exp_library contains architecture-independent files.
  2144.           exp_exec_library contains architecture-dependent files.
  2145.           Depending on your system, both directories may be totally
  2146.           empty.  The existence of the file $exp_exec_library/cat-
  2147.           buffers describes whether your /bin/cat buffers by default.
  2148.  
  2149.  
  2150.      PPPPRRRREEEETTTTTTTTYYYY----PPPPRRRRIIIINNNNTTTTIIIINNNNGGGG
  2151.           A vgrind definition is available for pretty-printing EEEExxxxppppeeeecccctttt
  2152.           scripts.  Assuming the vgrind definition supplied with the
  2153.           EEEExxxxppppeeeecccctttt distribution is correctly installed, you can use it
  2154.           as:
  2155.  
  2156.                        vgrind -lexpect file
  2157.  
  2158.  
  2159.      EEEEXXXXAAAAMMMMPPPPLLLLEEEESSSS
  2160.           It many not be apparent how to put everything together that
  2161.           the man page describes.  I encourage you to read and try out
  2162.           the examples in the example directory of the EEEExxxxppppeeeecccctttt
  2163.           distribution.  Some of them are real programs.  Others are
  2164.           simply illustrative of certain techniques, and of course, a
  2165.           couple are just quick hacks.  The INSTALL file has a quick
  2166.           overview of these programs.
  2167.  
  2168.           The EEEExxxxppppeeeecccctttt papers (see SEE ALSO) are also useful.  While
  2169.           some papers use syntax corresponding to earlier versions of
  2170.           Expect, the accompanying rationales are still valid and go
  2171.           into a lot more detail than this man page.
  2172.  
  2173.  
  2174.  
  2175.      Page 33                                         (printed 7/23/95)
  2176.  
  2177.  
  2178.  
  2179.  
  2180.  
  2181.  
  2182.      EEEEXXXXPPPPEEEECCCCTTTT((((1111))))       UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV ((((22229999 DDDDeeeecccceeeemmmmbbbbeeeerrrr 1111999999994444))))        EEEEXXXXPPPPEEEECCCCTTTT((((1111))))
  2183.  
  2184.  
  2185.  
  2186.      CCCCAAAAVVVVEEEEAAAATTTTSSSS
  2187.           Extensions may collide with Expect's command names.  For
  2188.           example, sssseeeennnndddd is defined by Tk for an entirely different
  2189.           purpose.  For this reason, most of the EEEExxxxppppeeeecccctttt commands are
  2190.           also available as "exp_XXXX".  Commands and variables
  2191.           beginning with "exp", "inter", "spawn", and "timeout" do not
  2192.           have aliases.  Use the extended command names if you need
  2193.           this compatibility between environments.
  2194.  
  2195.           EEEExxxxppppeeeecccctttt takes a rather liberal view of scoping.  In
  2196.           particular, variables read by commands specific to the
  2197.           EEEExxxxppppeeeecccctttt program will be sought first from the local scope,
  2198.           and if not found, in the global scope.  For example, this
  2199.           obviates the need to place "global timeout" in every
  2200.           procedure you write that uses eeeexxxxppppeeeecccctttt.  On the other hand,
  2201.           variables written are always in the local scope (unless a
  2202.           "global" command has been issued).  The most common problem
  2203.           this causes is when spawn is executed in a procedure.
  2204.           Outside the procedure, _s_p_a_w_n__i_d no longer exists, so the
  2205.           spawned process is no longer accessible simply because of
  2206.           scoping.  Add a "global spawn_id" to such a procedure.
  2207.  
  2208.           If you cannot enable the multispawning capability (i.e.,
  2209.           your system supports neither select (BSD *.*), poll (SVR>2),
  2210.           nor something equivalent), EEEExxxxppppeeeecccctttt will only be able to
  2211.           control a single process at a time.  In this case, do not
  2212.           attempt to set _s_p_a_w_n__i_d, nor should you execute processes
  2213.           via exec while a spawned process is running.  Furthermore,
  2214.           you will not be able to eeeexxxxppppeeeecccctttt from multiple processes
  2215.           (including the user as one) at the same time.
  2216.  
  2217.           Terminal parameters can have a big effect on scripts.  For
  2218.           example, if a script is written to look for echoing, it will
  2219.           misbehave if echoing is turned off.  For this reason, Expect
  2220.           forces sane terminal parameters by default.  Unfortunately,
  2221.           this can make things unpleasant for other programs.  As an
  2222.           example, the emacs shell wants to change the "usual"
  2223.           mappings: newlines get mapped to newlines instead of
  2224.           carriage-return newlines, and echoing is disabled.  This
  2225.           allows one to use emacs to edit the input line.
  2226.           Unfortunately, Expect cannot possibly guess this.
  2227.  
  2228.           You can request that Expect not override its default setting
  2229.           of terminal parameters, but you must then be very careful
  2230.           when writing scripts for such environments.  In the case of
  2231.           emacs, avoid depending upon things like echoing and end-of-
  2232.           line mappings.
  2233.  
  2234.           The commands that accepted arguments braced into a single
  2235.           list (the eeeexxxxppppeeeecccctttt variants and iiiinnnntttteeeerrrraaaacccctttt) use a heuristic to
  2236.           decide if the list is actually one argument or many.  The
  2237.           heuristic can fail only in the case when the list actually
  2238.  
  2239.  
  2240.  
  2241.      Page 34                                         (printed 7/23/95)
  2242.  
  2243.  
  2244.  
  2245.  
  2246.  
  2247.  
  2248.      EEEEXXXXPPPPEEEECCCCTTTT((((1111))))       UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV ((((22229999 DDDDeeeecccceeeemmmmbbbbeeeerrrr 1111999999994444))))        EEEEXXXXPPPPEEEECCCCTTTT((((1111))))
  2249.  
  2250.  
  2251.  
  2252.           does represent a single argument which has multiple embedded
  2253.           \n's with non-whitespace characters between them.  This
  2254.           seems sufficiently improbable, however the argument "-brace"
  2255.           can be used to force a single argument to be handled as a
  2256.           single argument.  This could conceivably be used with
  2257.           machine-generated Expect code.
  2258.  
  2259.      BBBBUUUUGGGGSSSS
  2260.           It was really tempting to name the program "sex" (for either
  2261.           "Smart EXec" or "Send-EXpect"), but good sense (or perhaps
  2262.           just Puritanism) prevailed.
  2263.  
  2264.           On some systems, when a shell is spawned, it complains about
  2265.           not being able to access the tty but runs anyway.  This
  2266.           means your system has a mechanism for gaining the
  2267.           controlling tty that EEEExxxxppppeeeecccctttt doesn't know about.  Please find
  2268.           out what it is, and send this information back to me.
  2269.  
  2270.           Ultrix 4.1 (at least the latest versions around here)
  2271.           considers timeouts of above 1000000 to be equivalent to 0.
  2272.  
  2273.           Telnet (verified only under SunOS 4.1.2) hangs if TERM is
  2274.           not set.  This is a problem under cron and at, which do not
  2275.           define TERM.  Thus, you must set it explicitly - to what
  2276.           type is usually irrelevant.  It just has to be set to
  2277.           something!  The following probably suffices for most cases.
  2278.  
  2279.                        set env(TERM) vt100
  2280.  
  2281.           Some implementations of ptys are designed so that the kernel
  2282.           throws away any unread output after 10 to 15 seconds (actual
  2283.           number is implementation-dependent) after the process has
  2284.           closed the file descriptor.  Thus EEEExxxxppppeeeecccctttt programs such as
  2285.  
  2286.                        spawn date
  2287.                        sleep 20
  2288.                        expect
  2289.  
  2290.           will fail.  To avoid this, invoke non-interactive programs
  2291.           with eeeexxxxeeeecccc rather than ssssppppaaaawwwwnnnn.  While such situations are
  2292.           conceivable, in practice I have never encountered a
  2293.           situation in which the final output of a truly interactive
  2294.           program would be lost due to this behavior.
  2295.  
  2296.           On the other hand, Cray UNICOS ptys throw away any unread
  2297.           output immediately after the process has closed the file
  2298.           descriptor.  I have reported this to Cray and they are
  2299.           working on a fix.
  2300.  
  2301.           Sometimes a delay is required between a prompt and a
  2302.           response, such as when a tty interface is changing UART
  2303.           settings or matching baud rates by looking for start/stop
  2304.  
  2305.  
  2306.  
  2307.      Page 35                                         (printed 7/23/95)
  2308.  
  2309.  
  2310.  
  2311.  
  2312.  
  2313.  
  2314.      EEEEXXXXPPPPEEEECCCCTTTT((((1111))))       UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV ((((22229999 DDDDeeeecccceeeemmmmbbbbeeeerrrr 1111999999994444))))        EEEEXXXXPPPPEEEECCCCTTTT((((1111))))
  2315.  
  2316.  
  2317.  
  2318.           bits.  Usually, all this is require is to sleep for a second
  2319.           or two.  A more robust technique is to retry until the
  2320.           hardware is ready to receive input.  The following example
  2321.           uses both strategies:
  2322.  
  2323.                        send "speed 9600\r";
  2324.                        sleep 1
  2325.                        expect {
  2326.                                timeout {send "\r"; exp_continue}
  2327.                                $prompt
  2328.                        }
  2329.  
  2330.  
  2331.  
  2332.      EEEEXXXXPPPPEEEECCCCTTTT HHHHIIIINNNNTTTTSSSS
  2333.           There are a couple of things about EEEExxxxppppeeeecccctttt that may be non-
  2334.           intuitive.  This section attempts to address some of these
  2335.           things with a couple of suggestions.
  2336.  
  2337.           A common expect problem is how to recognize shell prompts.
  2338.           Since these are customized differently by differently people
  2339.           and different shells, portably automating rlogin can be
  2340.           difficult without knowing the prompt.  A reasonable
  2341.           convention is to have users store a regular expression
  2342.           describing their prompt (in particular, the end of it) in
  2343.           the environment variable EXPECT_PROMPT.  Code like the
  2344.           following can be used.  If EXPECT_PROMPT doesn't exist, the
  2345.           code still has a good chance of functioning correctly.
  2346.  
  2347.           set prompt "(%|#|\\$) $"          ;# default prompt
  2348.           catch {set prompt $env(EXPECT_PROMPT)}
  2349.  
  2350.           expect -re $prompt
  2351.  
  2352.           I encourage you to write eeeexxxxppppeeeecccctttt patterns that include the
  2353.           end of whatever you expect to see.  This avoids the
  2354.           possibility of answering a question before seeing the entire
  2355.           thing.  In addition, while you may well be able to answer
  2356.           questions before seeing them entirely, if you answer early,
  2357.           your answer may appear echoed back in the middle of the
  2358.           question.  In other words, the resulting dialogue will be
  2359.           correct but look scrambled.
  2360.  
  2361.           Most prompts include a space character at the end.  For
  2362.           example, the prompt from ftp is 'f', 't', 'p', '>' and
  2363.           <blank>.  To match this prompt, you must account for each of
  2364.           these characters.  It is a common mistake not to include the
  2365.           blank.  Put the blank in explicitly.
  2366.  
  2367.           If you use a pattern of the form X*, the * will match all
  2368.           the output received from the end of X to the last thing
  2369.           received.  This sounds intuitive but can be somewhat
  2370.  
  2371.  
  2372.  
  2373.      Page 36                                         (printed 7/23/95)
  2374.  
  2375.  
  2376.  
  2377.  
  2378.  
  2379.  
  2380.      EEEEXXXXPPPPEEEECCCCTTTT((((1111))))       UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV ((((22229999 DDDDeeeecccceeeemmmmbbbbeeeerrrr 1111999999994444))))        EEEEXXXXPPPPEEEECCCCTTTT((((1111))))
  2381.  
  2382.  
  2383.  
  2384.           confusing because the phrase "last thing received" can vary
  2385.           depending upon the speed of the computer and the processing
  2386.           of I/O both by the kernel and the device driver.
  2387.  
  2388.           In particular, humans tend to see program output arriving in
  2389.           huge chunks (atomically) when in reality most programs
  2390.           produce output one line at a time.  Assuming this is the
  2391.           case, the * in the pattern of the previous paragraph may
  2392.           only match the end of the current line even though there
  2393.           seems to be more, because at the time of the match that was
  2394.           all the output that had been received.
  2395.  
  2396.           eeeexxxxppppeeeecccctttt has no way of knowing that further output is coming
  2397.           unless your pattern specifically accounts for it.
  2398.  
  2399.           Even depending on line-oriented buffering is unwise.  Not
  2400.           only do programs rarely make promises about the type of
  2401.           buffering they do, but system indigestion can break output
  2402.           lines up so that lines break at seemingly random places.
  2403.           Thus, if you can express the last few characters of a prompt
  2404.           when writing patterns, it is wise to do so.
  2405.  
  2406.           If you are waiting for a pattern in the last output of a
  2407.           program and the program emits something else instead, you
  2408.           will not be able to detect that with the ttttiiiimmmmeeeeoooouuuutttt keyword.
  2409.           The reason is that eeeexxxxppppeeeecccctttt will not timeout - instead it will
  2410.           get an eeeeooooffff indication.  Use that instead.  Even better, use
  2411.           both.  That way if that line is ever moved around, you won't
  2412.           have to edit the line itself.
  2413.  
  2414.           Newlines are usually converted to carriage return, linefeed
  2415.           sequences when output by the terminal driver.  Thus, if you
  2416.           want a pattern that explicitly matches the two lines, from,
  2417.           say, printf("foo\nbar"), you should use the pattern
  2418.           "foo\r\nbar".
  2419.  
  2420.           A similar translation occurs when reading from the user, via
  2421.           eeeexxxxppppeeeecccctttt____uuuusssseeeerrrr.  In this case, when you press return, it will
  2422.           be translated to a newline.  If EEEExxxxppppeeeecccctttt then passes that to a
  2423.           program which sets its terminal to raw mode (like telnet),
  2424.           there is going to be a problem, as the program expects a
  2425.           true return.  (Some programs are actually forgiving in that
  2426.           they will automatically translate newlines to returns, but
  2427.           most don't.)  Unfortunately, there is no way to find out
  2428.           that a program put its terminal into raw mode.
  2429.  
  2430.           Rather than manually replacing newlines with returns, the
  2431.           solution is to use the command "stty raw", which will stop
  2432.           the translation.  Note, however, that this means that you
  2433.           will no longer get the cooked line-editing features.
  2434.  
  2435.           iiiinnnntttteeeerrrraaaacccctttt implicitly sets your terminal to raw mode so this
  2436.  
  2437.  
  2438.  
  2439.      Page 37                                         (printed 7/23/95)
  2440.  
  2441.  
  2442.  
  2443.  
  2444.  
  2445.  
  2446.      EEEEXXXXPPPPEEEECCCCTTTT((((1111))))       UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV ((((22229999 DDDDeeeecccceeeemmmmbbbbeeeerrrr 1111999999994444))))        EEEEXXXXPPPPEEEECCCCTTTT((((1111))))
  2447.  
  2448.  
  2449.  
  2450.           problem will not arise then.
  2451.  
  2452.           It is often useful to store passwords (or other private
  2453.           information) in EEEExxxxppppeeeecccctttt scripts.  This is not recommended
  2454.           since anything that is stored on a computer is susceptible
  2455.           to being accessed by anyone.  Thus, interactively prompting
  2456.           for passwords from a script is a smarter idea than embedding
  2457.           them literally.  Nonetheless, sometimes such embedding is
  2458.           the only possibility.
  2459.  
  2460.           Unfortunately, the UNIX file system has no direct way of
  2461.           creating scripts which are executable but unreadable.
  2462.           Systems which support setgid shell scripts may indirectly
  2463.           simulate this as follows:
  2464.  
  2465.           Create the EEEExxxxppppeeeecccctttt script (that contains the secret data) as
  2466.           usual.  Make its permissions be 750 (-rwxr-x---) and owned
  2467.           by a trusted group, i.e., a group which is allowed to read
  2468.           it.  If necessary, create a new group for this purpose.
  2469.           Next, create a /bin/sh script with permissions 2751
  2470.           (-rwxr-s--x) owned by the same group as before.
  2471.  
  2472.           The result is a script which may be executed (and read) by
  2473.           anyone.  When invoked, it runs the EEEExxxxppppeeeecccctttt script.
  2474.  
  2475.      SSSSEEEEEEEE AAAALLLLSSSSOOOO
  2476.           TTTTccccllll(3), lllliiiibbbbeeeexxxxppppeeeecccctttt(3)
  2477.           "_E_x_p_l_o_r_i_n_g _E_x_p_e_c_t: _A _T_c_l-_B_a_s_e_d _T_o_o_l_k_i_t _f_o_r _A_u_t_o_m_a_t_i_n_g
  2478.           _I_n_t_e_r_a_c_t_i_v_e _P_r_o_g_r_a_m_s" by Don Libes, pp. 602, ISBN 1-56592-
  2479.           090-2, O'Reilly and Associates, 1995.
  2480.           "_e_x_p_e_c_t: _C_u_r_i_n_g _T_h_o_s_e _U_n_c_o_n_t_r_o_l_l_a_b_l_e _F_i_t_s _o_f _I_n_t_e_r_a_c_t_i_v_i_t_y"
  2481.           by Don Libes, Proceedings of the Summer 1990 USENIX
  2482.           Conference, Anaheim, California, June 11-15, 1990.
  2483.           "_U_s_i_n_g eeeexxxxppppeeeecccctttt to Automate System Administration Tasks" by
  2484.           Don Libes, Proceedings of the 1990 USENIX Large Installation
  2485.           Systems Administration Conference, Colorado Springs,
  2486.           Colorado, October 17-19, 1990.
  2487.           "_T_c_l: _A_n _E_m_b_e_d_d_a_b_l_e _C_o_m_m_a_n_d _L_a_n_g_u_a_g_e" by John Ousterhout,
  2488.           Proceedings of the Winter 1990 USENIX Conference,
  2489.           Washington, D.C., January 22-26, 1990.
  2490.           "_e_x_p_e_c_t: _S_c_r_i_p_t_s _f_o_r _C_o_n_t_r_o_l_l_i_n_g _I_n_t_e_r_a_c_t_i_v_e _P_r_o_g_r_a_m_s" by
  2491.           Don Libes, Computing Systems, Vol. 4, No. 2, University of
  2492.           California Press Journals, November 1991.
  2493.           "_R_e_g_r_e_s_s_i_o_n _T_e_s_t_i_n_g _a_n_d _C_o_n_f_o_r_m_a_n_c_e _T_e_s_t_i_n_g _I_n_t_e_r_a_c_t_i_v_e
  2494.           _P_r_o_g_r_a_m_s", by Don Libes, Proceedings of the Summer 1992
  2495.           USENIX Conference, pp. 135-144, San Antonio, TX, June 12-15,
  2496.           1992.
  2497.           "_K_i_b_i_t_z - _C_o_n_n_e_c_t_i_n_g _M_u_l_t_i_p_l_e _I_n_t_e_r_a_c_t_i_v_e _P_r_o_g_r_a_m_s
  2498.           _T_o_g_e_t_h_e_r", by Don Libes, Software - Practice & Experience,
  2499.           John Wiley & Sons, West Sussex, England, Vol. 23, No. 5,
  2500.           May, 1993.
  2501.           "_A _D_e_b_u_g_g_e_r _f_o_r _T_c_l _A_p_p_l_i_c_a_t_i_o_n_s", by Don Libes, Proceedings
  2502.  
  2503.  
  2504.  
  2505.      Page 38                                         (printed 7/23/95)
  2506.  
  2507.  
  2508.  
  2509.  
  2510.  
  2511.  
  2512.      EEEEXXXXPPPPEEEECCCCTTTT((((1111))))       UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV ((((22229999 DDDDeeeecccceeeemmmmbbbbeeeerrrr 1111999999994444))))        EEEEXXXXPPPPEEEECCCCTTTT((((1111))))
  2513.  
  2514.  
  2515.  
  2516.           of the 1993 Tcl/Tk Workshop, Berkeley, CA, June 10-11, 1993.
  2517.  
  2518.      AAAAUUUUTTTTHHHHOOOORRRR
  2519.           Don Libes, National Institute of Standards and Technology
  2520.  
  2521.      AAAACCCCKKKKNNNNOOOOWWWWLLLLEEEEDDDDGGGGEEEEMMMMEEEENNNNTTTTSSSS
  2522.           Thanks to John Ousterhout for Tcl, and Scott Paisley for
  2523.           inspiration.  Thanks to Rob Savoye for Expect's
  2524.           autoconfiguration code.
  2525.  
  2526.           The HISTORY file documents much of the evolution of eeeexxxxppppeeeecccctttt.
  2527.           It makes interesting reading and might give you further
  2528.           insight to this software.  Thanks to the people mentioned in
  2529.           it who sent me bug fixes and gave other assistance.
  2530.  
  2531.           Design and implementation of EEEExxxxppppeeeecccctttt was paid for in part by
  2532.           the U.S. government and is therefore in the public domain.
  2533.           However the author and NIST would like credit if this
  2534.           program and documentation or portions of them are used.
  2535.  
  2536.  
  2537.  
  2538.  
  2539.  
  2540.  
  2541.  
  2542.  
  2543.  
  2544.  
  2545.  
  2546.  
  2547.  
  2548.  
  2549.  
  2550.  
  2551.  
  2552.  
  2553.  
  2554.  
  2555.  
  2556.  
  2557.  
  2558.  
  2559.  
  2560.  
  2561.  
  2562.  
  2563.  
  2564.  
  2565.  
  2566.  
  2567.  
  2568.  
  2569.  
  2570.  
  2571.      Page 39                                         (printed 7/23/95)
  2572.  
  2573.  
  2574.  
  2575.